]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] re_cache: Respect disable_hyperscan option in loading functions
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 5 Feb 2026 08:58:53 +0000 (08:58 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 5 Feb 2026 08:58:53 +0000 (08:58 +0000)
Add checks for disable_hyperscan at the start of hyperscan loading
functions to prevent database loading when the option is set.

Previously, hyperscan databases would still be loaded even with
disable_hyperscan = true, causing unnecessary I/O and memory usage.

src/libserver/re_cache.c

index da76182936ff1c2f51b32f939499d63ab6829101..fc3e1e956a2d4e150e31b30c8b673e5693d5d34e 100644 (file)
@@ -3187,6 +3187,10 @@ rspamd_re_cache_load_hyperscan(struct rspamd_re_cache *cache,
        unsigned int total_classes, total_loaded = 0, total_regexps = 0;
        GString *missing_classes = NULL;
 
+       if (cache->disable_hyperscan) {
+               return RSPAMD_HYPERSCAN_UNSUPPORTED;
+       }
+
        total_classes = g_hash_table_size(cache->re_classes);
        g_hash_table_iter_init(&it, cache->re_classes);
 
@@ -3662,6 +3666,11 @@ void rspamd_re_cache_load_hyperscan_scoped_async(struct rspamd_re_cache *cache_h
                return;
        }
 
+       /* Check if hyperscan is disabled */
+       if (cache_head->disable_hyperscan) {
+               return;
+       }
+
        /* All file operations go through Lua backend */
        g_assert(rspamd_hs_cache_has_lua_backend());