From c936f801c0129f89a2c1d03bd1258675fdaeafd3 Mon Sep 17 00:00:00 2001 From: guybe7 Date: Thu, 2 Sep 2021 16:19:27 +0200 Subject: [PATCH] Fix two minor bugs (MIGRATE key args and getKeysUsingCommandTable) (#9455) 1. MIGRATE has a potnetial key arg in argv[3]. It should be reflected in the command table. 2. getKeysUsingCommandTable should never free getKeysResult, it is always freed by the caller) The reason we never encountered this double-free bug is that almost always getKeysResult uses the statis buffer and doesn't allocate a new one. (cherry picked from commit 6aa2285e32a6bc16fe2938bfb40d833db7d3752d) --- src/db.c | 1 - src/server.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/db.c b/src/db.c index 6f6d696e1..c8d6199d6 100644 --- a/src/db.c +++ b/src/db.c @@ -1623,7 +1623,6 @@ int getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, get * return no keys and expect the command implementation to report * an arity or syntax error. */ if (cmd->flags & CMD_MODULE || cmd->arity < 0) { - getKeysFreeResult(result); result->numkeys = 0; return 0; } else { diff --git a/src/server.c b/src/server.c index 43cb81b85..065028e27 100644 --- a/src/server.c +++ b/src/server.c @@ -870,7 +870,7 @@ struct redisCommand redisCommandTable[] = { {"migrate",migrateCommand,-6, "write random @keyspace @dangerous", - 0,migrateGetKeys,0,0,0,0,0,0}, + 0,migrateGetKeys,3,3,1,0,0,0}, {"asking",askingCommand,1, "fast @keyspace",