Mercurial > sdl-ios-xcode
comparison src/cdrom/freebsd/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 |
---|---|
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 /* Add this drive to our list */ | 111 /* Add this drive to our list */ |
112 i = SDL_numcds; | 112 i = SDL_numcds; |
113 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); | 113 SDL_cdlist[i] = SDL_strdup(drive); |
114 if ( SDL_cdlist[i] == NULL ) { | 114 if ( SDL_cdlist[i] == NULL ) { |
115 SDL_OutOfMemory(); | 115 SDL_OutOfMemory(); |
116 return; | 116 return; |
117 } | 117 } |
118 SDL_strcpy(SDL_cdlist[i], drive); | |
119 SDL_cdmode[i] = stbuf->st_rdev; | 118 SDL_cdmode[i] = stbuf->st_rdev; |
120 ++SDL_numcds; | 119 ++SDL_numcds; |
121 #ifdef DEBUG_CDROM | 120 #ifdef DEBUG_CDROM |
122 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); | 121 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); |
123 #endif | 122 #endif |
150 | 149 |
151 /* Look in the environment for our CD-ROM drive list */ | 150 /* Look in the environment for our CD-ROM drive list */ |
152 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ | 151 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ |
153 if ( SDLcdrom != NULL ) { | 152 if ( SDLcdrom != NULL ) { |
154 char *cdpath, *delim; | 153 char *cdpath, *delim; |
155 cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); | 154 size_t len = SDL_strlen(SDLcdrom)+1; |
155 cdpath = SDL_stack_alloc(char, len); | |
156 if ( cdpath != NULL ) { | 156 if ( cdpath != NULL ) { |
157 SDL_strcpy(cdpath, SDLcdrom); | 157 SDL_strlcpy(cdpath, SDLcdrom, len); |
158 SDLcdrom = cdpath; | 158 SDLcdrom = cdpath; |
159 do { | 159 do { |
160 delim = SDL_strchr(SDLcdrom, ':'); | 160 delim = SDL_strchr(SDLcdrom, ':'); |
161 if ( delim ) { | 161 if ( delim ) { |
162 *delim++ = '\0'; | 162 *delim++ = '\0'; |
168 SDLcdrom = delim; | 168 SDLcdrom = delim; |
169 } else { | 169 } else { |
170 SDLcdrom = NULL; | 170 SDLcdrom = NULL; |
171 } | 171 } |
172 } while ( SDLcdrom ); | 172 } while ( SDLcdrom ); |
173 SDL_free(cdpath); | 173 SDL_stack_free(cdpath); |
174 } | 174 } |
175 | 175 |
176 /* If we found our drives, there's nothing left to do */ | 176 /* If we found our drives, there's nothing left to do */ |
177 if ( SDL_numcds > 0 ) { | 177 if ( SDL_numcds > 0 ) { |
178 return(0); | 178 return(0); |