summaryrefslogtreecommitdiff
path: root/deps/lua
diff options
context:
space:
mode:
authorMeir Shpilraien (Spielrein) <meir@redis.com>2021-11-28 11:33:09 +0200
committerGitHub <noreply@github.com>2021-11-28 11:33:09 +0200
commita8c1253b6fd1d85ba33a8749e14e4fa515508df0 (patch)
tree4d8d37178f66a28776c95e38e93574118f8ca95f /deps/lua
parentacf3495eb823df8d1f358b1fe59b759fcc49666f (diff)
downloadredis-a8c1253b6fd1d85ba33a8749e14e4fa515508df0.tar.gz
Fix Lua C API violation on lua msgpack lib. (#9832)
msgpack lib missed using lua_checkstack and so on rare cases overflow the stack by at most 2 elements. This is a violation of the Lua C API. Notice that Lua allocates additional 5 more elements on top of lua->stack_last so Redis does not access an invalid memory. But it is an API violation and we should avoid it. This PR also added a new Lua compilation option. The new option can be enable using environment variable called LUA_DEBUG. If set to `yes` (by default `no`), Lua will be compiled without optimizations and with debug symbols (`-O0 -g`). In addition, in this new mode, Lua will be compiled with the `-DLUA_USE_APICHECK` flag that enables extended Lua C API validations. In addition, set LUA_DEBUG=yes on daily valgrind flow so we will be able to catch Lua C API violations in the future.
Diffstat (limited to 'deps/lua')
-rw-r--r--deps/lua/src/lua_cmsgpack.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/deps/lua/src/lua_cmsgpack.c b/deps/lua/src/lua_cmsgpack.c
index 892154793..49c6dc7b0 100644
--- a/deps/lua/src/lua_cmsgpack.c
+++ b/deps/lua/src/lua_cmsgpack.c
@@ -435,6 +435,7 @@ int table_is_an_array(lua_State *L) {
stacktop = lua_gettop(L);
+ luaL_checkstack(L, 2, "in function table_is_an_array");
lua_pushnil(L);
while(lua_next(L,-2)) {
/* Stack: ... key value */