mirror of https://mirror.osredm.com/root/redis.git
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) {
|
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)
|
if (cmd)
|
||||||
*err = sdsnew("Wrong number of args calling Redis command from script");
|
*err = sdsnew("Wrong number of args calling Redis command from script");
|
||||||
else
|
else
|
||||||
|
|
|
@ -598,6 +598,11 @@ start_server {tags {"scripting"}} {
|
||||||
set e
|
set e
|
||||||
} {ERR Number of keys can't be negative}
|
} {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)} {
|
test {Correct handling of reused argv (issue #1939)} {
|
||||||
run_script {
|
run_script {
|
||||||
for i = 0, 10 do
|
for i = 0, 10 do
|
||||||
|
|
Loading…
Reference in New Issue