diff options
author | Max Kellermann <max@duempel.org> | 2008-09-07 13:38:59 +0200 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-09 00:55:39 -0700 |
commit | 9e53c28046bae4a02387aba5ddaddc74f7bcf246 (patch) | |
tree | 190c3bb482e8799da5a5499780a3ce0128449a42 /src/command.c | |
parent | ff06a92213c0d430f93552188cc569a5fa506e18 (diff) | |
download | mpd-9e53c28046bae4a02387aba5ddaddc74f7bcf246.tar.gz mpd-9e53c28046bae4a02387aba5ddaddc74f7bcf246.tar.xz mpd-9e53c28046bae4a02387aba5ddaddc74f7bcf246.zip |
playlist: moved "repeat" and "random" value checks to command.c
Client's input values should be validated by the command
implementation, and the core libraries shouldn't talk to the client
directly if possible. Thus, setPlaylistRepeatStatus() and
setPlaylistRandomStatus() don't get the file descriptor, and cannot
fail (return void).
Diffstat (limited to '')
-rw-r--r-- | src/command.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/command.c b/src/command.c index bc646804e..77548664f 100644 --- a/src/command.c +++ b/src/command.c @@ -771,7 +771,15 @@ static int handleRepeat(int fd, mpd_unused int *permission, if (check_int(fd, &status, argv[1], need_integer) < 0) return -1; - return setPlaylistRepeatStatus(fd, status); + + if (status != 0 && status != 1) { + commandError(fd, ACK_ERROR_ARG, + "\"%i\" is not 0 or 1", status); + return -1; + } + + setPlaylistRepeatStatus(status); + return 0; } static int handleRandom(int fd, mpd_unused int *permission, @@ -781,7 +789,15 @@ static int handleRandom(int fd, mpd_unused int *permission, if (check_int(fd, &status, argv[1], need_integer) < 0) return -1; - return setPlaylistRandomStatus(fd, status); + + if (status != 0 && status != 1) { + commandError(fd, ACK_ERROR_ARG, + "\"%i\" is not 0 or 1", status); + return -1; + } + + setPlaylistRandomStatus(status); + return 0; } static int handleStats(int fd, mpd_unused int *permission, |