mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 16:40:50 +00:00
scripting: no eval with negative key count
Negative key count causes segfault in Lua functions. Fixes #1842 Closes #1843
This commit is contained in:
parent
1a5e5b6bd4
commit
f17f8521f0
@ -910,6 +910,9 @@ void evalGenericCommand(redisClient *c, int evalsha) {
|
||||
if (numkeys > (c->argc - 3)) {
|
||||
addReplyError(c,"Number of keys can't be greater than number of args");
|
||||
return;
|
||||
} else if (numkeys < 0) {
|
||||
addReplyError(c,"Number of keys can't be negative");
|
||||
return;
|
||||
}
|
||||
|
||||
/* We obtain the script SHA1, then check if this function is already
|
||||
|
@ -358,6 +358,11 @@ start_server {tags {"scripting"}} {
|
||||
return redis.call("get", "key")
|
||||
} 0
|
||||
} {12039611435714932082}
|
||||
|
||||
test {Verify negative arg count is error instead of crash (issue #1842)} {
|
||||
catch { r eval { return "hello" } -12 } e
|
||||
set e
|
||||
} {ERR Number of keys can't be negative}
|
||||
}
|
||||
|
||||
# Start a new server since the last test in this stanza will kill the
|
||||
|
Loading…
x
Reference in New Issue
Block a user