aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_security.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/cpp_api/s_security.cpp')
-rw-r--r--src/script/cpp_api/s_security.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp
index 316b19926..2222dec3f 100644
--- a/src/script/cpp_api/s_security.cpp
+++ b/src/script/cpp_api/s_security.cpp
@@ -30,7 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <algorithm>
#include <iostream>
-
#define SECURE_API(lib, name) \
lua_pushcfunction(L, sl_##lib##_##name); \
lua_setfield(L, -2, #name);
@@ -572,16 +571,18 @@ bool ScriptApiSecurity::checkPath(lua_State *L, const char *path,
// Allow paths in mod path
// Don't bother if write access isn't important, since it will be handled later
- if (write_required || write_allowed != NULL) {
- const ModSpec *mod = gamedef->getModSpec(mod_name);
- if (mod) {
- str = fs::AbsolutePath(mod->path);
- if (!str.empty() && fs::PathStartsWith(abs_path, str)) {
- if (write_allowed) *write_allowed = true;
- return true;
- }
+// if (write_required || write_allowed != NULL) {
+
+ // Do bother, rather than compare a few hundred strings when the mod is just trying to access its own stuff
+ const ModSpec *mod = gamedef->getModSpec(mod_name);
+ if (mod) {
+ str = fs::AbsolutePath(mod->path);
+ if (!str.empty() && fs::PathStartsWith(abs_path, str)) {
+ if (write_allowed) *write_allowed = true;
+ return true;
}
}
+// }
}
lua_pop(L, 1); // Pop mod name
@@ -820,7 +821,6 @@ int ScriptApiSecurity::sl_io_input(lua_State *L)
return 1;
}
-
int ScriptApiSecurity::sl_io_output(lua_State *L)
{
if (lua_isstring(L, 1)) {