Use LuaErrors in security check macros
Throwing a LuaError calls destructors as it propagates up the stack, wheres lua_error just executes a longjmp.master
parent
04e311a36d
commit
88fbe7ca1e
|
@ -25,9 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
#define CHECK_SECURE_PATH(L, path) \
|
#define CHECK_SECURE_PATH(L, path) \
|
||||||
if (!ScriptApiSecurity::checkPath(L, path)) { \
|
if (!ScriptApiSecurity::checkPath(L, path)) { \
|
||||||
lua_pushstring(L, (std::string("Attempt to access external file ") + \
|
throw LuaError(std::string("Attempt to access external file ") + \
|
||||||
path + " with mod security on.").c_str()); \
|
path + " with mod security on."); \
|
||||||
lua_error(L); \
|
|
||||||
}
|
}
|
||||||
#define CHECK_SECURE_PATH_OPTIONAL(L, path) \
|
#define CHECK_SECURE_PATH_OPTIONAL(L, path) \
|
||||||
if (ScriptApiSecurity::isSecure(L)) { \
|
if (ScriptApiSecurity::isSecure(L)) { \
|
||||||
|
|
|
@ -77,8 +77,7 @@ int ModApiUtil::l_get_us_time(lua_State *L)
|
||||||
#define CHECK_SECURE_SETTING(L, name) \
|
#define CHECK_SECURE_SETTING(L, name) \
|
||||||
if (ScriptApiSecurity::isSecure(L) && \
|
if (ScriptApiSecurity::isSecure(L) && \
|
||||||
name.compare(0, 7, "secure.") == 0) { \
|
name.compare(0, 7, "secure.") == 0) { \
|
||||||
lua_pushliteral(L, "Attempt to set secure setting."); \
|
throw LuaError("Attempt to set secure setting."); \
|
||||||
lua_error(L); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setting_set(name, value)
|
// setting_set(name, value)
|
||||||
|
|
Loading…
Reference in New Issue