From 6054089fa8f030cb6e43c2dbb6d486d2ad195013 Mon Sep 17 00:00:00 2001 From: Itamar Haber Date: Sat, 9 Apr 2016 13:25:50 -0700 Subject: [PATCH] Stops SPLICE from accepting negative counts --- src/modules/helloworld.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/helloworld.c b/src/modules/helloworld.c index 8598de895..09e2f1b24 100644 --- a/src/modules/helloworld.c +++ b/src/modules/helloworld.c @@ -97,7 +97,8 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, } long long count; - if (RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) { + if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || + (count < 0)) { RedisModule_CloseKey(srckey); RedisModule_CloseKey(dstkey); return RedisModule_ReplyWithError(ctx,"ERR invalid count"); @@ -141,8 +142,11 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar } long long count; - if (RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) + if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || + (count < 0)) + { return RedisModule_ReplyWithError(ctx,"ERR invalid count"); + } while(count-- > 0) { RedisModuleString *ele;