Skip to content

Commit

Permalink
Fix secure io.open without mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja committed Nov 24, 2016
1 parent 0d1c959 commit 9e10f9f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/script/cpp_api/s_security.cpp
Expand Up @@ -525,14 +525,19 @@ int ScriptApiSecurity::sl_g_require(lua_State *L)

int ScriptApiSecurity::sl_io_open(lua_State *L)
{
bool with_mode = lua_gettop(L) > 1;

luaL_checktype(L, 1, LUA_TSTRING);
const char *path = lua_tostring(L, 1);
CHECK_SECURE_PATH(L, path);

push_original(L, "io", "open");
lua_pushvalue(L, 1);
lua_pushvalue(L, 2);
lua_call(L, 2, 2);
if (with_mode) {
lua_pushvalue(L, 2);
}

lua_call(L, with_mode ? 2 : 1, 2);
return 2;
}

Expand Down

0 comments on commit 9e10f9f

Please sign in to comment.