Unverified Commit c275010f authored by Madelyn Olson's avatar Madelyn Olson Committed by GitHub
Browse files

Correctly handle minimum arity checks in scripts (#10171)

Correctly handle variable arity checks in scripts
parent 0343fe9f
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment