From 5a960a345038a9e7bdba661bc7061d2ed98d2f2a Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Wed, 8 Nov 2017 23:03:32 +0100 Subject: [PATCH] [mpd] Quoted argument unescaping fixed --- src/mpd.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index 78351531..3ccc6685 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -313,32 +313,36 @@ static char* mpd_pars_quoted(char **input) { char *arg; + char *src; + char *dst; + char ch; // skip double quote character (*input)++; - arg = *input; - - while (**input != '"') + src = dst = arg = *input; + while ((ch = *src) != '"') { - // A backslash character escapes the following character - if (**input == '\\') + // A backslash character escapes the following character and should be removed + if (ch == '\\') { - (*input)++; + ch = *(++src); } + *dst++ = ch; - if (**input == 0) + if (ch == 0) { // Error handling for missing double quote at end of parameter DPRINTF(E_LOG, L_MPD, "Error missing closing double quote in argument\n"); + *input = src; return NULL; } - (*input)++; + ++src; } - **input = '\0'; - (*input)++; + *dst = '\0'; + *input = ++src; return arg; }