Permalink
Browse files

Scripting: require at least one argument for redis.call().

Redis used to crash with a call like the following:

    EVAL "redis.call()" 0

Now the explicit check for at least one argument prevents the problem.

This commit fixes issue #655.
  • Loading branch information...
1 parent 1373216 commit edfaa64f49ecaf5183ce6b6e0855c4c679445042 @antirez committed Aug 31, 2012
Showing with 13 additions and 0 deletions.
  1. +7 −0 src/scripting.c
  2. +6 −0 tests/unit/scripting.tcl
View
@@ -167,6 +167,13 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
redisClient *c = server.lua_client;
sds reply;
+ /* Require at least one argument */
+ if (argc == 0) {
+ luaPushError(lua,
+ "Please specify at least one argument for redis.call()");
+ return 1;
+ }
+
/* Build the arguments vector */
argv = zmalloc(sizeof(robj*)*argc);
for (j = 0; j < argc; j++) {
View
@@ -145,6 +145,12 @@ start_server {tags {"scripting"}} {
set e
} {*not allowed after*}
+ test {EVAL - No arguments to redis.call/pcall is considered an error} {
+ set e {}
+ catch {r eval {return redis.call()} 0} e
+ set e
+ } {*one argument*}
+
test {EVAL - redis.call variant raises a Lua error on Redis cmd error (1)} {
set e {}
catch {

0 comments on commit edfaa64

Please sign in to comment.