summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-03-10 16:43:38 +0100
committerantirez <antirez@gmail.com>2014-03-11 11:10:33 +0100
commitab8e1bbcdcf3756255c956f3c50a8c5c822dd4c3 (patch)
treedac7bfc71460909e3c2d2a8ef82467b4da498870
parent94129415bf1d02fc2798521192354015dbd9f652 (diff)
downloadredis-ab8e1bbcdcf3756255c956f3c50a8c5c822dd4c3.tar.gz
DEBUG CMDKEYS: provide some guarantee to getKeysFromCommand().
getKeysFromCommand() is designed to be called with the command arguments passing the basic arity checks described in the command table. DEBUG CMDKEYS must provide the same guarantees for calling getKeysFromCommand() to be safe.
-rw-r--r--src/debug.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/debug.c b/src/debug.c
index e9863e2fc..198334b9d 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -370,7 +370,13 @@ void debugCommand(redisClient *c) {
if (!cmd) {
addReplyError(c,"Invalid command specified");
return;
+ } else if ((cmd->arity > 0 && cmd->arity != c->argc-2) ||
+ ((c->argc-2) < -cmd->arity))
+ {
+ addReplyError(c,"Invalid number of arguments specified for command");
+ return;
}
+
keys = getKeysFromCommand(cmd,c->argv+2,c->argc-2,&numkeys);
addReplyMultiBulkLen(c,numkeys);
for (j = 0; j < numkeys; j++) addReplyBulk(c,c->argv[keys[j]+2]);