diff options
author | antirez <antirez@gmail.com> | 2017-04-19 16:17:08 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2017-04-19 16:17:08 +0200 |
commit | 7d9dd80db3c4bc028072071d87bd97ea171195f5 (patch) | |
tree | 067294eb0ebdfbc05b0ee2bf791d8c3f87a34d41 | |
parent | 189a12afb4df2986d4671cdebae3c96c4f0945c2 (diff) | |
download | redis-7d9dd80db3c4bc028072071d87bd97ea171195f5.tar.gz |
Fix getKeysUsingCommandTable() in cluster mode.
Close #3940.
-rw-r--r-- | src/db.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -1133,11 +1133,24 @@ int *getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, in *numkeys = 0; return NULL; } + last = cmd->lastkey; if (last < 0) last = argc+last; keys = zmalloc(sizeof(int)*((last - cmd->firstkey)+1)); for (j = cmd->firstkey; j <= last; j += cmd->keystep) { - serverAssert(j < argc); + if (j >= argc) { + /* Modules command do not have dispatch time arity checks, so + * we need to handle the case where the user passed an invalid + * number of arguments here. In this case we return no keys + * and expect the module command to report an arity error. */ + if (cmd->flags & CMD_MODULE) { + zfree(keys); + *numkeys = 0; + return NULL; + } else { + serverPanic("Redis built-in command declared keys positions not matching the arity requirements."); + } + } keys[i++] = j; } *numkeys = i; |