commit 3003f8f: [Minor] Add fail-safety for settings post load

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Dec 30 17:28:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-12-30 17:00:52 +0000
URL: https://github.com/rspamd/rspamd/commit/3003f8f75fc3fa01012a9ebd20b0bdd332c938d7

[Minor] Add fail-safety for settings post load

---
 lualib/lua_settings.lua | 4 ++++
 src/lua/lua_task.c      | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lualib/lua_settings.lua b/lualib/lua_settings.lua
index 5779cea85..e0fc58b9d 100644
--- a/lualib/lua_settings.lua
+++ b/lualib/lua_settings.lua
@@ -32,6 +32,10 @@ local lua_util = require "lua_util"
 local rspamd_logger = require "rspamd_logger"
 
 local function register_settings_cb(from_postload)
+  if not from_postload then
+    assert(false, 'invalid invocation')
+  end
+
   if not post_init_performed then
     all_symbols = rspamd_config:get_symbols()
 
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 9cc037796..38b22f489 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -5774,7 +5774,7 @@ lua_task_set_settings_id (lua_State *L)
 				rspamd_config_find_settings_id_ref (task->cfg, id);
 
 		if (selt == NULL) {
-			return luaL_error (L, "settings id %u is unknown", id);
+			return luaL_error (L, "settings id %f is unknown", (lua_Number)id);
 		}
 		if (task->settings_elt) {
 			/* Overwrite existing settings from Lua */


More information about the Commits mailing list