Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c275010f
Unverified
Commit
c275010f
authored
Jan 24, 2022
by
Madelyn Olson
Committed by
GitHub
Jan 24, 2022
Browse files
Correctly handle minimum arity checks in scripts (#10171)
Correctly handle variable arity checks in scripts
parent
0343fe9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/script.c
View file @
c275010f
...
@@ -284,7 +284,7 @@ void scriptKill(client *c, int is_eval) {
...
@@ -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
...
...
tests/unit/scripting.tcl
View file @
c275010f
...
@@ -598,6 +598,11 @@ start_server {tags {"scripting"}} {
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment