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';
|
s[MAXPATHLEN] = '\0';
|
||||||
|
/* this is safe, notice actlen > MAXPATHLEN-1 above */
|
||||||
strcpy(s,actualPath);
|
strcpy(s,actualPath);
|
||||||
strcat(s,"/");
|
strcat(s,"/");
|
||||||
|
|
||||||
|
37
src/player.c
37
src/player.c
@ -301,29 +301,42 @@ int getPlayerError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char * getPlayerErrorStr() {
|
char * getPlayerErrorStr() {
|
||||||
static char error[2*MAXPATHLEN];
|
static char * error = NULL;
|
||||||
|
int errorlen = MAXPATHLEN+1024;
|
||||||
PlayerControl * pc = &(getPlayerData()->playerControl);
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
||||||
|
|
||||||
|
error = realloc(error,errorlen+1);
|
||||||
|
memset(error,0,errorlen+1);
|
||||||
|
|
||||||
switch(pc->error) {
|
switch(pc->error) {
|
||||||
case PLAYER_ERROR_FILENOTFOUND:
|
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);
|
pc->erroredFile);
|
||||||
return error;
|
break;
|
||||||
case PLAYER_ERROR_FILE:
|
case PLAYER_ERROR_FILE:
|
||||||
sprintf(error,"problems decoding \"%s\"",pc->erroredFile);
|
snprintf(error,errorlen,"problems decoding \"%s\"",
|
||||||
return error;
|
pc->erroredFile);
|
||||||
|
break;
|
||||||
case PLAYER_ERROR_AUDIO:
|
case PLAYER_ERROR_AUDIO:
|
||||||
sprintf(error,"problems opening audio device");
|
snprintf(error,errorlen,"problems opening audio device");
|
||||||
return error;
|
break;
|
||||||
case PLAYER_ERROR_SYSTEM:
|
case PLAYER_ERROR_SYSTEM:
|
||||||
sprintf(error,"system error occured");
|
snprintf(error,errorlen,"system error occured");
|
||||||
return error;
|
break;
|
||||||
case PLAYER_ERROR_UNKTYPE:
|
case PLAYER_ERROR_UNKTYPE:
|
||||||
sprintf(error,"file type of \"%s\" is unknown",pc->erroredFile);
|
snprintf(error,errorlen,"file type of \"%s\" is unknown",
|
||||||
return error;
|
pc->erroredFile);
|
||||||
default:
|
default:
|
||||||
return NULL;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errorlen = strlen(error);
|
||||||
|
error = realloc(error,errorlen+1);
|
||||||
|
|
||||||
|
if(errorlen) return error;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void playerCloseAudio() {
|
void playerCloseAudio() {
|
||||||
|
Loading…
Reference in New Issue
Block a user