]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix HTML fuzzy cache key to prevent overwriting text cache
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 5 Oct 2025 16:06:57 +0000 (17:06 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 5 Oct 2025 16:06:57 +0000 (17:06 +0100)
HTML fuzzy hashes were incorrectly cached using the standard text fuzzy
cache key via fuzzy_cmd_set_cached(), causing HTML hashes to overwrite
text hashes for the same part. Now HTML fuzzy uses the dedicated
html_cache_key for both read and write operations, preventing cache
conflicts and ensuring proper retrieval of HTML fuzzy data.

src/plugins/fuzzy_check.c

index 395fc2512a4fa6e7e0d0132a0b925f361bffa0c5..5139783e569486e6d81e58caf3cfe89db5125638 100644 (file)
@@ -2364,7 +2364,13 @@ fuzzy_cmd_from_html_part(struct rspamd_task *task,
                        return NULL;
                }
 
-               fuzzy_cmd_set_cached(rule, task, mp, cached);
+               /* Save to HTML-specific cache (not standard text cache) */
+               if (!html_cached_ptr) {
+                       html_cached_ptr = rspamd_mempool_alloc0(task->task_pool, sizeof(*html_cached_ptr) *
+                                                                                                                                                (MESSAGE_FIELD(task, parts)->len + 1));
+                       rspamd_mempool_set_variable(task->task_pool, html_cache_key, html_cached_ptr, NULL);
+               }
+               html_cached_ptr[mp->part_number] = cached;
        }
 
        io = rspamd_mempool_alloc(task->task_pool, sizeof(*io));