From f339a53e3cb53352e9560d864c715514938f7b79 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 3 Apr 2019 22:27:41 +0200 Subject: [PATCH] client/Process: move basic syntax check to the beginning of method This catches lines within command lists as well. --- src/client/Process.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/client/Process.cxx b/src/client/Process.cxx index 401244eef..f8b4340a6 100644 --- a/src/client/Process.cxx +++ b/src/client/Process.cxx @@ -55,6 +55,16 @@ Client::ProcessCommandList(bool list_ok, CommandResult Client::ProcessLine(char *line) noexcept { + if (IsUpperAlphaASCII(*line)) { + /* no valid MPD command begins with an upper case + letter; this could be a badly routed HTTP + request */ + FormatWarning(client_domain, + "[%u] malformed command \"%s\"", + num, line); + return CommandResult::CLOSE; + } + CommandResult ret; if (StringIsEqual(line, "noidle")) { @@ -119,14 +129,6 @@ Client::ProcessLine(char *line) noexcept } else if (StringIsEqual(line, CLIENT_LIST_OK_MODE_BEGIN)) { cmd_list.Begin(true); ret = CommandResult::OK; - } else if (IsUpperAlphaASCII(*line)) { - /* no valid MPD command begins with an upper - case letter; this could be a badly routed - HTTP request */ - FormatWarning(client_domain, - "[%u] malformed command \"%s\"", - num, line); - ret = CommandResult::CLOSE; } else { FormatDebug(client_domain, "[%u] process command \"%s\"",