comparison src/audio/SDL_audiodev.c @ 1379:c0a74f199ecf

Use only safe string functions
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 Feb 2006 23:46:34 +0000
parents c71e05b4dc2e
children d910939febfa
comparison
equal deleted inserted replaced
1378:dc0e13e7e1ae 1379:c0a74f199ecf
87 } 87 }
88 } while ( exists && (audio_fd < 0) ); 88 } while ( exists && (audio_fd < 0) );
89 audiodev = audiopath; 89 audiodev = audiopath;
90 } 90 }
91 if ( path != NULL ) { 91 if ( path != NULL ) {
92 SDL_strncpy(path, audiodev, maxlen); 92 SDL_strlcpy(path, audiodev, maxlen);
93 path[maxlen-1] = '\0'; 93 path[maxlen-1] = '\0';
94 } 94 }
95 return(audio_fd); 95 return(audio_fd);
96 } 96 }
97 97
134 if ( audiodev == NULL ) { 134 if ( audiodev == NULL ) {
135 return -1; 135 return -1;
136 } 136 }
137 audio_fd = open(audiodev, flags, 0); 137 audio_fd = open(audiodev, flags, 0);
138 if ( path != NULL ) { 138 if ( path != NULL ) {
139 SDL_strncpy(path, audiodev, maxlen); 139 SDL_strlcpy(path, audiodev, maxlen);
140 path[maxlen-1] = '\0'; 140 path[maxlen-1] = '\0';
141 } 141 }
142 return audio_fd; 142 return audio_fd;
143 } 143 }
144 144
164 164
165 if ( stat(audiopath, &sb) == 0 ) { 165 if ( stat(audiopath, &sb) == 0 ) {
166 audio_fd = open(audiopath, flags, 0); 166 audio_fd = open(audiopath, flags, 0);
167 if ( audio_fd > 0 ) { 167 if ( audio_fd > 0 ) {
168 if ( path != NULL ) { 168 if ( path != NULL ) {
169 SDL_strncpy( path, audiopath, maxlen ); 169 SDL_strlcpy( path, audiopath, maxlen );
170 path[maxlen-1] = '\0';
171 } 170 }
172 return audio_fd; 171 return audio_fd;
173 } 172 }
174 } 173 }
175 } 174 }