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.
This commit is contained in:
Max Kellermann 2018-03-04 11:46:11 +01:00
parent 79535212c8
commit dadd3ca671
2 changed files with 6 additions and 0 deletions

2
NEWS
View File

@ -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)

View File

@ -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);
}