comparison src/cdrom/qnx/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
122 } 122 }
123 123
124 /* Add this drive to our list */ 124 /* Add this drive to our list */
125 125
126 i = SDL_numcds; 126 i = SDL_numcds;
127 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); 127 SDL_cdlist[i] = SDL_strdup(drive);
128 if (SDL_cdlist[i] == NULL) 128 if (SDL_cdlist[i] == NULL)
129 { 129 {
130 SDL_OutOfMemory(); 130 SDL_OutOfMemory();
131 return; 131 return;
132 } 132 }
133 SDL_strcpy(SDL_cdlist[i], drive);
134 SDL_cdmode[i] = stbuf->st_rdev; 133 SDL_cdmode[i] = stbuf->st_rdev;
135 ++SDL_numcds; 134 ++SDL_numcds;
136 } 135 }
137 } 136 }
138 137
167 /* Look in the environment for our CD-ROM drive list */ 166 /* Look in the environment for our CD-ROM drive list */
168 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ 167 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
169 if ( SDLcdrom != NULL ) 168 if ( SDLcdrom != NULL )
170 { 169 {
171 char *cdpath, *delim; 170 char *cdpath, *delim;
172 171 size_t len = SDL_strlen(SDLcdrom)+1;
173 cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); 172 cdpath = SDL_stack_alloc(len);
174 if (cdpath != NULL) 173 if (cdpath != NULL)
175 { 174 {
176 SDL_strcpy(cdpath, SDLcdrom); 175 SDL_strlcpy(cdpath, SDLcdrom, len);
177 SDLcdrom = cdpath; 176 SDLcdrom = cdpath;
178 do { 177 do {
179 delim = SDL_strchr(SDLcdrom, ':'); 178 delim = SDL_strchr(SDLcdrom, ':');
180 if (delim) 179 if (delim)
181 { 180 {
192 else 191 else
193 { 192 {
194 SDLcdrom = NULL; 193 SDLcdrom = NULL;
195 } 194 }
196 } while (SDLcdrom); 195 } while (SDLcdrom);
197 SDL_free(cdpath); 196 SDL_stack_free(cdpath);
198 } 197 }
199 198
200 /* If we found our drives, there's nothing left to do */ 199 /* If we found our drives, there's nothing left to do */
201 if (SDL_numcds > 0) 200 if (SDL_numcds > 0)
202 { 201 {