Correctly handle minimum arity checks in scripts (#10171)
Correctly handle variable arity checks in scripts
This commit is contained in:
parent
0343fe9fa5
commit
c275010fff
@ -284,7 +284,7 @@ void scriptKill(client *c, int is_eval) {
|
||||
}
|
||||
|
||||
static int scriptVerifyCommandArity(struct redisCommand *cmd, int argc, sds *err) {
|
||||
if (!cmd || ((cmd->arity > 0 && cmd->arity != argc) || (argc < cmd->arity))) {
|
||||
if (!cmd || ((cmd->arity > 0 && cmd->arity != argc) || (argc < -cmd->arity))) {
|
||||
if (cmd)
|
||||
*err = sdsnew("Wrong number of args calling Redis command from script");
|
||||
else
|
||||
|
@ -598,6 +598,11 @@ start_server {tags {"scripting"}} {
|
||||
set e
|
||||
} {ERR Number of keys can't be negative}
|
||||
|
||||
test {Scripts can handle commands with incorrect arity} {
|
||||
assert_error "*Wrong number of args calling Redis command from script" {run_script "redis.call('set','invalid')" 0}
|
||||
assert_error "*Wrong number of args calling Redis command from script" {run_script "redis.call('incr')" 0}
|
||||
}
|
||||
|
||||
test {Correct handling of reused argv (issue #1939)} {
|
||||
run_script {
|
||||
for i = 0, 10 do
|
||||
|
Loading…
x
Reference in New Issue
Block a user