summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authormeir <meir@redis.com>2022-02-15 20:18:49 +0200
committermeir <meir@redis.com>2022-04-27 00:37:40 +0300
commitefa162bcd7ab1477c07d8ee85537e27c0cb1524b (patch)
tree900e0b068a2f9c4dd351206caf2a368b12bb94bb /deps
parent3731580b6b80c586322cadc6bc4be2b8b2bbb206 (diff)
downloadredis-efa162bcd7ab1477c07d8ee85537e27c0cb1524b.tar.gz
Protect any table which is reachable from globals and added globals white list.
The white list is done by setting a metatable on the global table before initializing any library. The metatable set the `__newindex` field to a function that check the white list before adding the field to the table. Fields which is not on the white list are simply ignored. After initialization phase is done we protect the global table and each table that might be reachable from the global table. For each table we also protect the table metatable if exists.
Diffstat (limited to 'deps')
-rw-r--r--deps/lua/src/lapi.c8
-rw-r--r--deps/lua/src/lua.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/deps/lua/src/lapi.c b/deps/lua/src/lapi.c
index 1a9455629..e8ef41ea2 100644
--- a/deps/lua/src/lapi.c
+++ b/deps/lua/src/lapi.c
@@ -1099,3 +1099,11 @@ LUA_API void lua_enablereadonlytable (lua_State *L, int objindex, int enabled) {
t->readonly = enabled;
}
+LUA_API int lua_isreadonlytable (lua_State *L, int objindex) {
+ const TValue* o = index2adr(L, objindex);
+ api_check(L, ttistable(o));
+ Table* t = hvalue(o);
+ api_check(L, t != hvalue(registry(L)));
+ return t->readonly;
+}
+
diff --git a/deps/lua/src/lua.h b/deps/lua/src/lua.h
index e478d14c0..280ef2382 100644
--- a/deps/lua/src/lua.h
+++ b/deps/lua/src/lua.h
@@ -359,6 +359,7 @@ struct lua_Debug {
};
LUA_API void lua_enablereadonlytable (lua_State *L, int index, int enabled);
+LUA_API int lua_isreadonlytable (lua_State *L, int index);
/* }====================================================================== */