Mercurial > sdl-ios-xcode
comparison src/cdrom/bsdi/SDL_syscdrom.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 |
---|---|
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 /* Add this drive to our list */ | 225 /* Add this drive to our list */ |
226 i = SDL_numcds; | 226 i = SDL_numcds; |
227 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); | 227 SDL_cdlist[i] = SDL_strdup(drive); |
228 if ( SDL_cdlist[i] == NULL ) { | 228 if ( SDL_cdlist[i] == NULL ) { |
229 SDL_OutOfMemory(); | 229 SDL_OutOfMemory(); |
230 return; | 230 return; |
231 } | 231 } |
232 SDL_strcpy(SDL_cdlist[i], drive); | |
233 SDL_cdmode[i] = stbuf->st_rdev; | 232 SDL_cdmode[i] = stbuf->st_rdev; |
234 ++SDL_numcds; | 233 ++SDL_numcds; |
235 #ifdef DEBUG_CDROM | 234 #ifdef DEBUG_CDROM |
236 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); | 235 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); |
237 #endif | 236 #endif |
263 | 262 |
264 /* Look in the environment for our CD-ROM drive list */ | 263 /* Look in the environment for our CD-ROM drive list */ |
265 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ | 264 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ |
266 if ( SDLcdrom != NULL ) { | 265 if ( SDLcdrom != NULL ) { |
267 char *cdpath, *delim; | 266 char *cdpath, *delim; |
268 cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); | 267 size_t len = SDL_strlen(SDLcdrom)+1; |
268 cdpath = SDL_stack_alloc(char, len); | |
269 if ( cdpath != NULL ) { | 269 if ( cdpath != NULL ) { |
270 SDL_strcpy(cdpath, SDLcdrom); | 270 SDL_strlcpy(cdpath, SDLcdrom, len); |
271 SDLcdrom = cdpath; | 271 SDLcdrom = cdpath; |
272 do { | 272 do { |
273 delim = SDL_strchr(SDLcdrom, ':'); | 273 delim = SDL_strchr(SDLcdrom, ':'); |
274 if ( delim ) { | 274 if ( delim ) { |
275 *delim++ = '\0'; | 275 *delim++ = '\0'; |
281 SDLcdrom = delim; | 281 SDLcdrom = delim; |
282 } else { | 282 } else { |
283 SDLcdrom = NULL; | 283 SDLcdrom = NULL; |
284 } | 284 } |
285 } while ( SDLcdrom ); | 285 } while ( SDLcdrom ); |
286 SDL_free(cdpath); | 286 SDL_stack_free(cdpath); |
287 } | 287 } |
288 | 288 |
289 /* If we found our drives, there's nothing left to do */ | 289 /* If we found our drives, there's nothing left to do */ |
290 if ( SDL_numcds > 0 ) { | 290 if ( SDL_numcds > 0 ) { |
291 return(0); | 291 return(0); |