Skip to content
Permalink
Browse files Browse the repository at this point in the history
Disable lua load(), loadstring() bytcode loading
  • Loading branch information
aidanholm committed Feb 16, 2020
1 parent e77a692 commit fc522ff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crawl-ref/source/clua.cc
Expand Up @@ -304,6 +304,9 @@ int CLua::loadfile(lua_State *ls, const char *filename, bool trusted,
while (!f.eof())
script += f.get_line() + "\n";

if (script[0] == 0x1b)
abort();

// prefixing with @ stops lua from adding [string "%s"]
return luaL_loadbuffer(ls, &script[0], script.length(),
("@" + file).c_str());
Expand Down Expand Up @@ -796,6 +799,8 @@ void CLua::init_libraries()

lua_pushcfunction(_state, lua_loadstring);
lua_setglobal(_state, "loadstring");
lua_pushnil(_state);
lua_setglobal(_state, "load");

// Open Crawl bindings
cluaopen_kills(_state);
Expand Down

0 comments on commit fc522ff

Please sign in to comment.