]> git.saurik.com Git - redis.git/commitdiff
add sanity check to zunionInterBlockClientOnSwappedKeys, as the number of keys used...
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Fri, 7 May 2010 10:59:34 +0000 (12:59 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Fri, 7 May 2010 10:59:34 +0000 (12:59 +0200)
redis.c

diff --git a/redis.c b/redis.c
index 55a2ac213bf6de0d98565829114fe28321de1756..46f97273a007817b8d91e6e9d4fa76d049811043 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -9562,13 +9562,15 @@ static void waitForMultipleSwappedKeys(redisClient *c, struct redisCommand *cmd,
     }
 }
 
     }
 }
 
-/* Preload keys needed for the ZUNION and ZINTER commands. */
+/* Preload keys needed for the ZUNION and ZINTER commands.
+ * Note that the number of keys to preload is user-defined, so we need to
+ * apply a sanity check against argc. */
 static void zunionInterBlockClientOnSwappedKeys(redisClient *c, struct redisCommand *cmd, int argc, robj **argv) {
     int i, num;
     REDIS_NOTUSED(cmd);
 static void zunionInterBlockClientOnSwappedKeys(redisClient *c, struct redisCommand *cmd, int argc, robj **argv) {
     int i, num;
     REDIS_NOTUSED(cmd);
-    REDIS_NOTUSED(argc);
 
     num = atoi(argv[2]->ptr);
 
     num = atoi(argv[2]->ptr);
+    if (num > (argc-3)) return;
     for (i = 0; i < num; i++) {
         waitForSwappedKey(c,argv[3+i]);
     }
     for (i = 0; i < num; i++) {
         waitForSwappedKey(c,argv[3+i]);
     }