aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-02 01:26:15 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-02 01:26:15 +0000
commitefe8a04c70f1dde3c62e88f514433515631db858 (patch)
treed6ba8eb0acd4a299149596718cd4bfb6224f20f1 /src/decode.c
parentbef55ff3de4a16100b8115950c10f3cede755d3c (diff)
downloadmpd-efe8a04c70f1dde3c62e88f514433515631db858.tar.gz
mpd-efe8a04c70f1dde3c62e88f514433515631db858.tar.xz
mpd-efe8a04c70f1dde3c62e88f514433515631db858.zip
validate url's before adding to playlist
git-svn-id: https://svn.musicpd.org/mpd/trunk@1289 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/decode.c21
1 files changed, 15 insertions, 6 deletions
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) {