From ab05b704239be0fe7289f5da5391bff560b64f4c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 12 Aug 2014 14:39:30 +0200 Subject: [PATCH] ClientProcess: close connection when client sends HTTP request --- NEWS | 1 + src/client/ClientProcess.cxx | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/NEWS b/NEWS index 4dd243f36..0ba8476c4 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ver 0.21 (not yet released) * protocol - "tagtypes" can be used to hide tags - "find" and "search" can sort + - close connection when client sends HTTP request * tags - new tag "OriginalDate" * decoder diff --git a/src/client/ClientProcess.cxx b/src/client/ClientProcess.cxx index b5591cd1b..c7c71ab47 100644 --- a/src/client/ClientProcess.cxx +++ b/src/client/ClientProcess.cxx @@ -23,6 +23,7 @@ #include "command/AllCommands.hxx" #include "Log.hxx" #include "util/StringAPI.hxx" +#include "util/CharUtil.hxx" #define CLIENT_LIST_MODE_BEGIN "command_list_begin" #define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin" @@ -118,6 +119,14 @@ client_process_line(Client &client, char *line) } else if (StringIsEqual(line, CLIENT_LIST_OK_MODE_BEGIN)) { client.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\"", + client.num, line); + ret = CommandResult::CLOSE; } else { FormatDebug(client_domain, "[%u] process command \"%s\"",