projects
/
oweals
/
minetest.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0d1c959
)
Fix secure io.open without mode
author
ShadowNinja
<shadowninja@minetest.net>
Thu, 24 Nov 2016 14:58:21 +0000
(09:58 -0500)
committer
ShadowNinja
<shadowninja@minetest.net>
Thu, 24 Nov 2016 14:58:21 +0000
(09:58 -0500)
src/script/cpp_api/s_security.cpp
patch
|
blob
|
history
diff --git
a/src/script/cpp_api/s_security.cpp
b/src/script/cpp_api/s_security.cpp
index 3a8f724fe0024a77f06e5d2dd3c63847d8123793..5a64c249c977fce52b8055cfc9b05860906bda8e 100644
(file)
--- 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;
}