summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_security.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-20 13:30:50 +0200
committerGitHub <noreply@github.com>2017-08-20 13:30:50 +0200
commit1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3 (patch)
tree03dd0c39e323c7f0b1f06014ff30e74f429bfa01 /src/script/cpp_api/s_security.cpp
parent50669cd2822a11570ae462972194eeb2d585a8c1 (diff)
downloadminetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.gz
minetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.bz2
minetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.zip
Modernize source code: last part (#6285)
* Modernize source code: last par * Use empty when needed * Use emplace_back instead of push_back when needed * For range-based loops * Initializers fixes * constructors, destructors default * c++ C stl includes
Diffstat (limited to 'src/script/cpp_api/s_security.cpp')
-rw-r--r--src/script/cpp_api/s_security.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp
index 761597701..690a3b47f 100644
--- a/src/script/cpp_api/s_security.cpp
+++ b/src/script/cpp_api/s_security.cpp
@@ -260,7 +260,7 @@ void ScriptApiSecurity::initializeSecurityClient()
static const char *os_whitelist[] = {
"clock",
"date",
- "difftime",
+ "difftime",
"time",
"setlocale",
};
@@ -504,7 +504,7 @@ bool ScriptApiSecurity::checkPath(lua_State *L, const char *path,
// by the operating system anyways.
return false;
}
- removed = component + (removed.empty() ? "" : DIR_DELIM + removed);
+ removed.append(component).append(removed.empty() ? "" : DIR_DELIM + removed);
abs_path = fs::AbsolutePath(cur_path);
}
if (abs_path.empty())
@@ -550,9 +550,9 @@ bool ScriptApiSecurity::checkPath(lua_State *L, const char *path,
// Allow read-only access to all mod directories
if (!write_required) {
- const std::vector<ModSpec> mods = gamedef->getMods();
- for (size_t i = 0; i < mods.size(); ++i) {
- str = fs::AbsolutePath(mods[i].path);
+ const std::vector<ModSpec> &mods = gamedef->getMods();
+ for (const ModSpec &mod : mods) {
+ str = fs::AbsolutePath(mod.path);
if (!str.empty() && fs::PathStartsWith(abs_path, str)) {
return true;
}
@@ -617,7 +617,9 @@ int ScriptApiSecurity::sl_g_load(lua_State *L)
int t = lua_type(L, -1);
if (t == LUA_TNIL) {
break;
- } else if (t != LUA_TSTRING) {
+ }
+
+ if (t != LUA_TSTRING) {
lua_pushnil(L);
lua_pushliteral(L, "Loader didn't return a string");
return 2;