aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-07 13:38:59 +0200
committerMax Kellermann <max@duempel.org>2008-09-07 13:38:59 +0200
commite1bf96672e8ef46b4ed20eba2c91efa048c4789c (patch)
tree22fd5495c789d974e0ffff385248528cb1e682f6 /src/command.c
parentd1df71ebbcb23456ca5985dea9cb06e2453f903e (diff)
downloadmpd-e1bf96672e8ef46b4ed20eba2c91efa048c4789c.tar.gz
mpd-e1bf96672e8ef46b4ed20eba2c91efa048c4789c.tar.xz
mpd-e1bf96672e8ef46b4ed20eba2c91efa048c4789c.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 'src/command.c')
-rw-r--r--src/command.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/command.c b/src/command.c
index 3e03c50b9..63ff03e96 100644
--- a/src/command.c
+++ b/src/command.c
@@ -773,7 +773,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,
@@ -783,7 +791,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,