From 53f728a0aec357f22f04af2d8cceccac8ff4237b Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Sat, 27 Mar 2004 02:52:59 +0000 Subject: just to be carfile, make sure to null terminate when using strncpy git-svn-id: https://svn.musicpd.org/mpd/trunk@506 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/decode.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/decode.c') diff --git a/src/decode.c b/src/decode.c index ac4fcb08a..5ae2133c6 100644 --- a/src/decode.c +++ b/src/decode.c @@ -116,6 +116,7 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc, if(dc->start || dc->error!=DECODE_ERROR_NOERROR) { strncpy(pc->erroredFile,pc->file,MAXPATHLEN); + pc->erroredFile[MAXPATHLEN] = '\0'; pc->error = PLAYER_ERROR_FILE; quitDecode(pc,dc); return -1; @@ -123,6 +124,7 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc, if(initAudio(af)<0) { strncpy(pc->erroredFile,pc->file,MAXPATHLEN); + pc->erroredFile[MAXPATHLEN] = '\0'; pc->error = PLAYER_ERROR_AUDIO; quitDecode(pc,dc); return -1; @@ -184,6 +186,7 @@ void decodeSeek(PlayerControl * pc, AudioFormat * af, DecoderControl * dc, else { \ if(initAudio(NULL)<0) { \ strncpy(pc->erroredFile,pc->file,MAXPATHLEN); \ + pc->erroredFile[MAXPATHLEN] = '\0' \ pc->error = PLAYER_ERROR_AUDIO; \ quitDecode(pc,dc); \ return; \ @@ -221,6 +224,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af, while(1) { if(dc->start) { strncpy(dc->file,pc->file,MAXPATHLEN); + dc->file[MAXPATHLEN] = '\0'; switch(pc->decodeType) { #ifdef HAVE_MAD case DECODE_TYPE_MP3: @@ -252,6 +256,9 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af, #endif default: ret = DECODE_ERROR_UNKTYPE; + strncpy(pc->erroredFile,dc->file, + MAXPATHLEN); + pc->erroredFile[MAXPATHLEN] = '\0'; } if(ret<0) { dc->error = DECODE_ERROR_FILE; @@ -273,6 +280,7 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af, } else if(pid<0) { strncpy(pc->erroredFile,pc->file,MAXPATHLEN); + pc->erroredFile[MAXPATHLEN] = '\0'; pc->error = PLAYER_ERROR_SYSTEM; return -1; } -- cgit v1.2.3