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)
73
73
74
74
void CLuaMain::InitSecurity (void )
75
75
{
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
+
76
92
lua_register (m_luaVM, " dofile" , CLuaUtilDefs::DisabledFunction);
77
93
lua_register (m_luaVM, " loadfile" , CLuaUtilDefs::DisabledFunction);
78
94
lua_register (m_luaVM, " require" , CLuaUtilDefs::DisabledFunction);
@@ -141,6 +157,7 @@ void CLuaMain::InitVM(void)
141
157
luaopen_table (m_luaVM);
142
158
luaopen_debug (m_luaVM);
143
159
luaopen_utf8 (m_luaVM);
160
+ luaopen_os (m_luaVM);
144
161
145
162
// Initialize security restrictions. Very important to prevent lua trojans and viruses!
146
163
InitSecurity ();
You can’t perform that action at this time.
0 commit comments