Skip to content
This repository
Browse code

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...
commit 46c31a150a0e6a67eaaf4b1e1146ec815cc1355e 1 parent 6276434
Salvatore Sanfilippo authored August 31, 2012
7  src/scripting.c
@@ -167,6 +167,13 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
167 167
     redisClient *c = server.lua_client;
168 168
     sds reply;
169 169
 
  170
+    /* Require at least one argument */
  171
+    if (argc == 0) {
  172
+        luaPushError(lua,
  173
+            "Please specify at least one argument for redis.call()");
  174
+        return 1;
  175
+    }
  176
+
170 177
     /* Build the arguments vector */
171 178
     argv = zmalloc(sizeof(robj*)*argc);
172 179
     for (j = 0; j < argc; j++) {
6  tests/unit/scripting.tcl
@@ -145,6 +145,12 @@ start_server {tags {"scripting"}} {
145 145
         set e
146 146
     } {*not allowed after*}
147 147
 
  148
+    test {EVAL - No arguments to redis.call/pcall is considered an error} {
  149
+        set e {}
  150
+        catch {r eval {return redis.call()} 0} e
  151
+        set e
  152
+    } {*one argument*}
  153
+
148 154
     test {EVAL - redis.call variant raises a Lua error on Redis cmd error (1)} {
149 155
         set e {}
150 156
         catch {

0 notes on commit 46c31a1

Please sign in to comment.
Something went wrong with that request. Please try again.