File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Client/mods/deathmatch/logic/lua Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,22 @@ void CLuaMain::ResetInstructionCount(void)
7373
7474void CLuaMain::InitSecurity (void )
7575{
76+ // Disable dangerous Lua Os library functions
77+ lua_getglobal (m_luaVM, " os" );
78+ lua_pushnil (m_luaVM);
79+ lua_setfield (m_luaVM, -2 , " execute" );
80+ lua_pushnil (m_luaVM);
81+ lua_setfield (m_luaVM, -2 , " rename" );
82+ lua_pushnil (m_luaVM);
83+ lua_setfield (m_luaVM, -2 , " remove" );
84+ lua_pushnil (m_luaVM);
85+ lua_setfield (m_luaVM, -2 , " exit" );
86+ lua_pushnil (m_luaVM);
87+ lua_setfield (m_luaVM, -2 , " getenv" );
88+ lua_pushnil (m_luaVM);
89+ lua_setfield (m_luaVM, -2 , " tmpname" );
90+ lua_pop (m_luaVM, 1 );
91+
7692 lua_register (m_luaVM, " dofile" , CLuaUtilDefs::DisabledFunction);
7793 lua_register (m_luaVM, " loadfile" , CLuaUtilDefs::DisabledFunction);
7894 lua_register (m_luaVM, " require" , CLuaUtilDefs::DisabledFunction);
@@ -141,6 +157,7 @@ void CLuaMain::InitVM(void)
141157 luaopen_table (m_luaVM);
142158 luaopen_debug (m_luaVM);
143159 luaopen_utf8 (m_luaVM);
160+ luaopen_os (m_luaVM);
144161
145162 // Initialize security restrictions. Very important to prevent lua trojans and viruses!
146163 InitSecurity ();
You can’t perform that action at this time.
0 commit comments