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
839767ad
Commit
839767ad
authored
Jan 20, 2015
by
antirez
Browse files
Panic on recursive calls to luaRedisGenericCommand().
Related to issue #2302.
parent
cf76af6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/scripting.c
View file @
839767ad
...
@@ -214,11 +214,22 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
...
@@ -214,11 +214,22 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
static
int
argv_size
=
0
;
static
int
argv_size
=
0
;
static
robj
*
cached_objects
[
LUA_CMD_OBJCACHE_SIZE
];
static
robj
*
cached_objects
[
LUA_CMD_OBJCACHE_SIZE
];
static
size_t
cached_objects_len
[
LUA_CMD_OBJCACHE_SIZE
];
static
size_t
cached_objects_len
[
LUA_CMD_OBJCACHE_SIZE
];
static
int
inuse
=
0
;
/* Recursive calls detection. */
/* By using Lua debug hooks it is possible to trigger a recursive call
* to luaRedisGenericCommand(), which normally should never happen.
* To make this function reentrant is futile and makes it slower, but
* we should at least detect such a misuse, and abort. */
if
(
inuse
)
{
redisPanic
(
"luaRedisGenericCommand() recursive call detected. Are you doing funny stuff with Lua debug hooks?"
);
}
inuse
++
;
/* Require at least one argument */
/* Require at least one argument */
if
(
argc
==
0
)
{
if
(
argc
==
0
)
{
luaPushError
(
lua
,
luaPushError
(
lua
,
"Please specify at least one argument for redis.call()"
);
"Please specify at least one argument for redis.call()"
);
inuse
--
;
return
1
;
return
1
;
}
}
...
@@ -273,6 +284,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
...
@@ -273,6 +284,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
}
}
luaPushError
(
lua
,
luaPushError
(
lua
,
"Lua redis() command arguments must be strings or integers"
);
"Lua redis() command arguments must be strings or integers"
);
inuse
--
;
return
1
;
return
1
;
}
}
...
@@ -426,8 +438,10 @@ cleanup:
...
@@ -426,8 +438,10 @@ cleanup:
* return the plain error. */
* return the plain error. */
lua_pushstring
(
lua
,
"err"
);
lua_pushstring
(
lua
,
"err"
);
lua_gettable
(
lua
,
-
2
);
lua_gettable
(
lua
,
-
2
);
inuse
--
;
return
lua_error
(
lua
);
return
lua_error
(
lua
);
}
}
inuse
--
;
return
1
;
return
1
;
}
}
...
...
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