Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
4024220f
Commit
4024220f
authored
Jun 28, 2014
by
Matt Stancliff
Committed by
antirez
Aug 27, 2014
Browse files
scripting: no eval with negative key count
Negative key count causes segfault in Lua functions. Fixes #1842 Closes #1843
parent
50669f7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/scripting.c
View file @
4024220f
...
@@ -909,6 +909,9 @@ void evalGenericCommand(redisClient *c, int evalsha) {
...
@@ -909,6 +909,9 @@ void evalGenericCommand(redisClient *c, int evalsha) {
if
(
numkeys
>
(
c
->
argc
-
3
))
{
if
(
numkeys
>
(
c
->
argc
-
3
))
{
addReplyError
(
c
,
"Number of keys can't be greater than number of args"
);
addReplyError
(
c
,
"Number of keys can't be greater than number of args"
);
return
;
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
/* We obtain the script SHA1, then check if this function is already
...
...
tests/unit/scripting.tcl
View file @
4024220f
...
@@ -358,6 +358,11 @@ start_server {tags {"scripting"}} {
...
@@ -358,6 +358,11 @@ start_server {tags {"scripting"}} {
return redis.call
(
"get"
,
"key"
)
return redis.call
(
"get"
,
"key"
)
}
0
}
0
}
{
12039611435714932082
}
}
{
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
# Start a new server since the last test in this stanza will kill the
...
...
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