diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-10 14:55:22 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-10 14:55:22 +0100 |
commit | ea79cda0ba71ccbaefc4fdd90e3a15714487124a (patch) | |
tree | acce1d516237f65bbe4e3c746eeca325f00d6083 /src/plugins | |
parent | a5bd97a363284ce99d43054a5b4ac57b83534327 (diff) | |
download | rspamd-ea79cda0ba71ccbaefc4fdd90e3a15714487124a.tar.gz rspamd-ea79cda0ba71ccbaefc4fdd90e3a15714487124a.zip |
[Fix] Fix occasional encryption of the cached data
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/fuzzy_check.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 6211b22f1..5c9ef7fe7 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -1653,9 +1653,20 @@ fuzzy_cmd_from_text_part (struct rspamd_task *task, } } else { - cached = rspamd_mempool_alloc0 (task->task_pool, sizeof (*cached)); additional_length = fuzzy_cmd_extension_length (task, rule); + cached = rspamd_mempool_alloc0 (task->task_pool, sizeof (*cached) + + additional_length); + /* + * Allocate extensions and never touch it except copying to avoid + * occasional encryption + */ cached->additional_length = additional_length; + cached->additional_data = ((guchar *)cached) + sizeof (*cached); + + if (additional_length > 0) { + fuzzy_cmd_write_extensions (task, rule, cached->additional_data, + additional_length); + } if (short_text) { enccmd = rspamd_mempool_alloc0 (task->task_pool, @@ -1678,13 +1689,7 @@ fuzzy_cmd_from_text_part (struct rspamd_task *task, cached->sh = NULL; additional_data = ((guchar *)enccmd) + sizeof (*enccmd); - - if (additional_length > 0) { - fuzzy_cmd_write_extensions (task, rule, additional_data, - additional_length); - } - - cached->additional_data = additional_data; + memcpy (additional_data, cached->additional_data, additional_length); } else { encshcmd = rspamd_mempool_alloc0 (task->task_pool, @@ -1724,13 +1729,7 @@ fuzzy_cmd_from_text_part (struct rspamd_task *task, cached->sh = sh; memcpy (cached->digest, shcmd->basic.digest, sizeof (cached->digest)); additional_data = ((guchar *)encshcmd) + sizeof (*encshcmd); - - if (additional_length > 0) { - fuzzy_cmd_write_extensions (task, rule, additional_data, - additional_length); - } - - cached->additional_data = additional_data; + memcpy (additional_data, cached->additional_data, additional_length); } /* |