some cleanups of sprintf's => snprintf's
git-svn-id: https://svn.musicpd.org/mpd/trunk@794 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
a5d6f1868e
commit
a7076a120b
1
src/ls.c
1
src/ls.c
@ -63,6 +63,7 @@ int lsPlaylists(FILE * fp, char * utf8path) {
|
||||
}
|
||||
|
||||
s[MAXPATHLEN] = '\0';
|
||||
/* this is safe, notice actlen > MAXPATHLEN-1 above */
|
||||
strcpy(s,actualPath);
|
||||
strcat(s,"/");
|
||||
|
||||
|
37
src/player.c
37
src/player.c
@ -301,29 +301,42 @@ int getPlayerError() {
|
||||
}
|
||||
|
||||
char * getPlayerErrorStr() {
|
||||
static char error[2*MAXPATHLEN];
|
||||
static char * error = NULL;
|
||||
int errorlen = MAXPATHLEN+1024;
|
||||
PlayerControl * pc = &(getPlayerData()->playerControl);
|
||||
|
||||
error = realloc(error,errorlen+1);
|
||||
memset(error,0,errorlen+1);
|
||||
|
||||
switch(pc->error) {
|
||||
case PLAYER_ERROR_FILENOTFOUND:
|
||||
sprintf(error,"file \"%s\" does not exist or is inaccesible",
|
||||
snprintf(error,errorlen,
|
||||
"file \"%s\" does not exist or is inaccesible",
|
||||
pc->erroredFile);
|
||||
return error;
|
||||
break;
|
||||
case PLAYER_ERROR_FILE:
|
||||
sprintf(error,"problems decoding \"%s\"",pc->erroredFile);
|
||||
return error;
|
||||
snprintf(error,errorlen,"problems decoding \"%s\"",
|
||||
pc->erroredFile);
|
||||
break;
|
||||
case PLAYER_ERROR_AUDIO:
|
||||
sprintf(error,"problems opening audio device");
|
||||
return error;
|
||||
snprintf(error,errorlen,"problems opening audio device");
|
||||
break;
|
||||
case PLAYER_ERROR_SYSTEM:
|
||||
sprintf(error,"system error occured");
|
||||
return error;
|
||||
snprintf(error,errorlen,"system error occured");
|
||||
break;
|
||||
case PLAYER_ERROR_UNKTYPE:
|
||||
sprintf(error,"file type of \"%s\" is unknown",pc->erroredFile);
|
||||
return error;
|
||||
snprintf(error,errorlen,"file type of \"%s\" is unknown",
|
||||
pc->erroredFile);
|
||||
default:
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
errorlen = strlen(error);
|
||||
error = realloc(error,errorlen+1);
|
||||
|
||||
if(errorlen) return error;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void playerCloseAudio() {
|
||||
|
Loading…
Reference in New Issue
Block a user