From fbffb52a647d005bbdfa40df9892239e02659c31 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 10 Mar 2014 16:43:38 +0100 Subject: [PATCH] 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. --- src/debug.c | 6 ++++++ 1 file changed, 6 insertions(+) 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]);