Skip to content

Commit

Permalink
Disable lua bytecode loading
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanholm committed Feb 13, 2020
1 parent e281fa6 commit 768f60d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crawl-ref/source/clua.cc
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,27 @@ void CLua::init_lua()
setregistry("__clua");
}

static int lua_loadstring(lua_State *ls)
{
const auto lua = luaL_checkstring(ls, 1);
if (lua[0] == 0x1b)
abort();
lua_settop(ls, 0);
if (luaL_loadstring(ls, lua))
{
lua_pushnil(ls);
lua_insert(ls, 1);
}
return lua_gettop(ls);
}

void CLua::init_libraries()
{
lua_stack_cleaner clean(state());

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

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

0 comments on commit 768f60d

Please sign in to comment.