Mercurial > sdl-ios-xcode
comparison src/cdrom/openbsd/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 |
---|---|
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 /* Add this drive to our list */ | 116 /* Add this drive to our list */ |
117 i = SDL_numcds; | 117 i = SDL_numcds; |
118 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); | 118 SDL_cdlist[i] = SDL_strdup(drive); |
119 if ( SDL_cdlist[i] == NULL ) { | 119 if ( SDL_cdlist[i] == NULL ) { |
120 SDL_OutOfMemory(); | 120 SDL_OutOfMemory(); |
121 return; | 121 return; |
122 } | 122 } |
123 SDL_strcpy(SDL_cdlist[i], drive); | |
124 SDL_cdmode[i] = stbuf->st_rdev; | 123 SDL_cdmode[i] = stbuf->st_rdev; |
125 ++SDL_numcds; | 124 ++SDL_numcds; |
126 #ifdef DEBUG_CDROM | 125 #ifdef DEBUG_CDROM |
127 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); | 126 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); |
128 #endif | 127 #endif |
159 | 158 |
160 /* Look in the environment for our CD-ROM drive list */ | 159 /* Look in the environment for our CD-ROM drive list */ |
161 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ | 160 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ |
162 if ( SDLcdrom != NULL ) { | 161 if ( SDLcdrom != NULL ) { |
163 char *cdpath, *delim; | 162 char *cdpath, *delim; |
164 cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); | 163 size_t len = SDL_strlen(SDLcdrom)+1; |
164 cdpath = SDL_stack_alloc(char, len); | |
165 if ( cdpath != NULL ) { | 165 if ( cdpath != NULL ) { |
166 SDL_strcpy(cdpath, SDLcdrom); | 166 SDL_strlcpy(cdpath, SDLcdrom, len); |
167 SDLcdrom = cdpath; | 167 SDLcdrom = cdpath; |
168 do { | 168 do { |
169 delim = SDL_strchr(SDLcdrom, ':'); | 169 delim = SDL_strchr(SDLcdrom, ':'); |
170 if ( delim ) { | 170 if ( delim ) { |
171 *delim++ = '\0'; | 171 *delim++ = '\0'; |
177 SDLcdrom = delim; | 177 SDLcdrom = delim; |
178 } else { | 178 } else { |
179 SDLcdrom = NULL; | 179 SDLcdrom = NULL; |
180 } | 180 } |
181 } while ( SDLcdrom ); | 181 } while ( SDLcdrom ); |
182 SDL_free(cdpath); | 182 SDL_stack_free(cdpath); |
183 } | 183 } |
184 | 184 |
185 /* If we found our drives, there's nothing left to do */ | 185 /* If we found our drives, there's nothing left to do */ |
186 if ( SDL_numcds > 0 ) { | 186 if ( SDL_numcds > 0 ) { |
187 return(0); | 187 return(0); |