From a6c10e9a1c37defe67c056ada3a41f62c404d5f7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 15 Feb 2021 20:25:41 +0100 Subject: [PATCH] protocol/ArgParser: check for invalid ranges Catch errors like that early, before invalid ranges get passed to internal MPD subsystems. --- NEWS | 2 ++ src/protocol/ArgParser.cxx | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/NEWS b/NEWS index e7fdf2154..9bda29812 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.22.5 (not yet released) +* protocol + - error for malformed ranges instead of ignoring silently * database - simple: fix missing CUE sheet metadata in "addid" command * tags diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx index 2cfac9b33..b5d05b473 100644 --- a/src/protocol/ArgParser.cxx +++ b/src/protocol/ArgParser.cxx @@ -110,6 +110,10 @@ ParseCommandArgRange(const char *s) return RangeArg::Single(range.start); } + if (!range.IsWellFormed()) + throw FormatProtocolError(ACK_ERROR_ARG, + "Malformed range: %s", s); + return range; }