comparison src/loadso/dlopen/SDL_sysloadso.c @ 1379:c0a74f199ecf

Use only safe string functions
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 Feb 2006 23:46:34 +0000
parents 19418e4422cb
children d910939febfa
comparison
equal deleted inserted replaced
1378:dc0e13e7e1ae 1379:c0a74f199ecf
40 40
41 void *SDL_LoadFunction(void *handle, const char *name) 41 void *SDL_LoadFunction(void *handle, const char *name)
42 { 42 {
43 void *symbol = dlsym(handle, name); 43 void *symbol = dlsym(handle, name);
44 if ( symbol == NULL ) { 44 if ( symbol == NULL ) {
45 char *_name = SDL_stack_alloc(char, 1+SDL_strlen(name)+1); 45 size_t len = 1+SDL_strlen(name)+1;
46 char *_name = SDL_stack_alloc(char, len);
46 _name[0] = '_'; 47 _name[0] = '_';
47 SDL_strcpy(&_name[1], name); 48 SDL_strlcpy(&_name[1], name, len);
48 symbol = dlsym(handle, name); 49 symbol = dlsym(handle, name);
49 SDL_stack_free(_name); 50 SDL_stack_free(_name);
50 if ( symbol == NULL ) { 51 if ( symbol == NULL ) {
51 SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror()); 52 SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror());
52 } 53 }