]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix maybe_adjust_type callback return and add nil check
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 19 Nov 2025 11:50:28 +0000 (11:50 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 19 Nov 2025 11:50:28 +0000 (11:50 +0000)
Fixed bug where maybe_adjust_type returned only mtype instead of data,mtype
when mtype=='callback'. Added defensive check to prevent passing nil/empty
URL to rspamd_config:add_map which would cause assertion failure.

lualib/lua_maps.lua

index 9cdee089cc08fbfc190f3cd26deccd0f1f8fa310..b112bbda0f6090f7a5a30281be42d380fd1e7f75 100644 (file)
@@ -73,7 +73,7 @@ local function maybe_adjust_type(data, mtype)
   }
 
   if mtype == 'callback' then
-    return mtype
+    return data, mtype
   end
 
   for _, t in ipairs(known_types) do
@@ -303,6 +303,10 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
 
   if type(opt) == 'string' then
     opt, mtype = maybe_adjust_type(opt, mtype)
+    if not opt or opt == '' then
+      rspamd_logger.errx(rspamd_config, 'invalid map url (nil or empty): %s', description)
+      return nil
+    end
     local cache_key = map_hash_key(opt, mtype)
     if not callback and maps_cache[cache_key] then
       rspamd_logger.infox(rspamd_config, 'reuse url for %s(%s)',