From dadd3ca6716f37fdb530a48e9ef98e0fa6bc6a89 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 4 Mar 2018 11:46:11 +0100 Subject: [PATCH] protocol/ArgParser: disallow negative seek times Instead of stopping playback (due to seek time overflow), reject the seek command. Closes #240 Relative negative values (with "seekcur") are still allowed, and MPD will fix the resulting position if it turns out to be negative. But the "seek" and "seekid" commands use an unsigned time stamp which must not be negative. --- NEWS | 2 ++ src/protocol/ArgParser.cxx | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/NEWS b/NEWS index 5c40e4f6c..670cb3256 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.20.19 (not yet released) +* protocol + - validate absolute seek time, reject negative values * macOS: fix crash bug ver 0.20.18 (2018/02/24) diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx index 47fdfa405..bdc28bcbf 100644 --- a/src/protocol/ArgParser.cxx +++ b/src/protocol/ArgParser.cxx @@ -164,6 +164,10 @@ SongTime ParseCommandArgSongTime(const char *s) { auto value = ParseCommandArgFloat(s); + if (value < 0) + throw FormatProtocolError(ACK_ERROR_ARG, + "Negative value not allowed: %s", s); + return SongTime::FromS(value); }