aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-04-16 15:01:06 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-04-16 15:01:06 +0000
commita7076a120bed21479ef726e61009d67c06019431 (patch)
treeb292d8906582b99c6d85ec804a51f4cb975dfbff /src
parenta5d6f1868ecebfd4ee831ace7eeee6eb1bbeebb0 (diff)
downloadmpd-a7076a120bed21479ef726e61009d67c06019431.tar.gz
mpd-a7076a120bed21479ef726e61009d67c06019431.tar.xz
mpd-a7076a120bed21479ef726e61009d67c06019431.zip
some cleanups of sprintf's => snprintf's
git-svn-id: https://svn.musicpd.org/mpd/trunk@794 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/ls.c1
-rw-r--r--src/player.c37
2 files changed, 26 insertions, 12 deletions
diff --git a/src/ls.c b/src/ls.c
index 6b9b46ed1..d651e202c 100644
--- a/src/ls.c
+++ b/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,"/");
diff --git a/src/player.c b/src/player.c
index b73652bb6..57e489f64 100644
--- a/src/player.c
+++ b/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() {