diff options
author | ShadowNinja <shadowninja@minetest.net> | 2016-11-24 09:58:21 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2016-11-24 09:58:21 -0500 |
commit | 9e10f9f49a558050d36a49db619bf8f5eb3853c0 (patch) | |
tree | 449f1c083a73049ec41d028f2927b242fd816053 /src/script | |
parent | 0d1c9598a0d2a4f21dc57de32efca2dc52b6b146 (diff) | |
download | minetest-9e10f9f49a558050d36a49db619bf8f5eb3853c0.tar.gz minetest-9e10f9f49a558050d36a49db619bf8f5eb3853c0.tar.bz2 minetest-9e10f9f49a558050d36a49db619bf8f5eb3853c0.zip |
Fix secure io.open without mode
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/cpp_api/s_security.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp index 3a8f724fe..5a64c249c 100644 --- a/src/script/cpp_api/s_security.cpp +++ b/src/script/cpp_api/s_security.cpp @@ -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; } |