]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Ensure stable re_cache class hashes independent of other classes
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 10 Jan 2026 17:19:32 +0000 (17:19 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 10 Jan 2026 17:19:32 +0000 (17:19 +0000)
Previously, the global regexp index `i` was included in per-class hashes,
which caused class B's hash to change when class A got new regexps
(because indices shift). This made Redis caching ineffective as databases
were constantly being recompiled.

Now the global index is only included in the global hash, not in per-class
hashes, ensuring each class hash depends only on its own regexps.

src/libserver/re_cache.c

index e8ad04723d64e88bca119f10b093212dc678b38a..abfcf4fa5faa98e4c5c9392cd896d0799082842d 100644 (file)
@@ -556,9 +556,8 @@ void rspamd_re_cache_init(struct rspamd_re_cache *cache, struct rspamd_config *c
                                                                         sizeof(fl));
                rspamd_cryptobox_hash_update(&st_global, (const unsigned char *) &fl,
                                                                         sizeof(fl));
-               /* Numeric order */
-               rspamd_cryptobox_hash_update(re_class->st, (const unsigned char *) &i,
-                                                                        sizeof(i));
+               /* Global index - only in global hash, not per-class (to avoid
+                * class hash instability when other classes change) */
                rspamd_cryptobox_hash_update(&st_global, (const unsigned char *) &i,
                                                                         sizeof(i));
        }