Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use LuaErrors in security check macros
Throwing a LuaError calls destructors as it propagates up the stack,
wheres lua_error just executes a longjmp.
  • Loading branch information
ShadowNinja committed Mar 7, 2016
1 parent 04e311a commit 88fbe7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/script/cpp_api/s_security.h
Expand Up @@ -25,9 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#define CHECK_SECURE_PATH(L, path) \
if (!ScriptApiSecurity::checkPath(L, path)) { \
lua_pushstring(L, (std::string("Attempt to access external file ") + \
path + " with mod security on.").c_str()); \
lua_error(L); \
throw LuaError(std::string("Attempt to access external file ") + \
path + " with mod security on."); \
}
#define CHECK_SECURE_PATH_OPTIONAL(L, path) \
if (ScriptApiSecurity::isSecure(L)) { \
Expand Down
3 changes: 1 addition & 2 deletions src/script/lua_api/l_util.cpp
Expand Up @@ -77,8 +77,7 @@ int ModApiUtil::l_get_us_time(lua_State *L)
#define CHECK_SECURE_SETTING(L, name) \
if (ScriptApiSecurity::isSecure(L) && \
name.compare(0, 7, "secure.") == 0) { \
lua_pushliteral(L, "Attempt to set secure setting."); \
lua_error(L); \
throw LuaError("Attempt to set secure setting."); \
}

// setting_set(name, value)
Expand Down

0 comments on commit 88fbe7c

Please sign in to comment.