From efe8a04c70f1dde3c62e88f514433515631db858 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Wed, 2 Jun 2004 01:26:15 +0000 Subject: validate url's before adding to playlist git-svn-id: https://svn.musicpd.org/mpd/trunk@1289 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/decode.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/decode.c') diff --git a/src/decode.c b/src/decode.c index 4d04e4c74..e01e63f67 100644 --- a/src/decode.c +++ b/src/decode.c @@ -256,13 +256,19 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) { int ret; InputStream inStream; InputPlugin * plugin; - char path[MAXPATHLEN+1]; + char * path; if(isRemoteUrl(pc->utf8url)) { - strncpy(path, pc->utf8url, MAXPATHLEN); + path = utf8StrToLatin1Dup(pc->utf8url); } - else strncpy(path, rmp2amp(utf8ToFsCharset(pc->utf8url)), MAXPATHLEN); - path[MAXPATHLEN] = '\0'; + else path = strdup(rmp2amp(utf8ToFsCharset(pc->utf8url))); + + if(!path) { + dc->error = DECODE_ERROR_FILE; + dc->state = DECODE_STATE_STOP; + dc->start = 0; + return; + } dc->metadataSet = 0; memset(dc->metadata, 0, DECODE_METADATA_LENGTH); @@ -275,9 +281,9 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) { if(openInputStream(&inStream, path) < 0) { dc->error = DECODE_ERROR_FILE; - dc->start = 0; - dc->stop = 0; dc->state = DECODE_STATE_STOP; + dc->start = 0; + free(path); return; } @@ -291,6 +297,7 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) { if(dc->stop) { dc->state = DECODE_STATE_STOP; dc->stop = 0; + free(path); return; } @@ -345,6 +352,8 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) { dc->stop = 0; dc->state = DECODE_STATE_STOP; } + + free(path); } int decoderInit(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) { -- cgit v1.2.3