Nuke function 'loadfile' for sandboxing reasons'

This commit is contained in:
2021-02-28 16:39:37 -05:00
parent 35260fa4eb
commit 0afe80fa2f

View File

@@ -70,14 +70,18 @@ static void load_builtin_class(lua_State *L, const char *name, lua_CFunction fun
}
static void source_install_builtins(lua_State *L) {
LuaVar nullstring, stringclass;
LuaStack LS(L, nullstring, stringclass);
LuaVar nullstring, stringclass, globtab;
LuaStack LS(L, nullstring, stringclass, globtab);
luaopen_base(L);
load_builtin_class(L, "table", luaopen_table);
load_builtin_class(L, "string", luaopen_string);
load_builtin_class(L, "math", luaopen_math);
load_builtin_class(L, "debug", luaopen_debug);
// Nuke a few of the builtin functions for sandboxing reasons.
LS.getglobaltable(globtab);
LS.rawset(globtab, "loadfile", LuaNil);
// Set the metatable for strings.
// Normally, this would be done by luaopen_string, but we're
// messing with the tables so we have to redo it.