diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-27 23:44:04 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-27 23:44:04 +0100 |
commit | 47b87877734ceea722d42ee9c92f727332e40a92 (patch) | |
tree | c7fdcd19aedc0bd7fb685a72b635fcf3dd1c5ee2 /src/plugins/fuzzy_check.c | |
parent | 60b538bb04cdf53f9b09f1d6955067544fe657aa (diff) | |
download | rspamd-47b87877734ceea722d42ee9c92f727332e40a92.tar.gz rspamd-47b87877734ceea722d42ee9c92f727332e40a92.zip |
[Fix] Do not add exact hashes from different parts
Diffstat (limited to 'src/plugins/fuzzy_check.c')
-rw-r--r-- | src/plugins/fuzzy_check.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index ccca8eddc..a63201bd3 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -2270,8 +2270,8 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule, struct rspamd_mime_text_part *part; struct rspamd_mime_part *mime_part; struct rspamd_image *image; - struct fuzzy_cmd_io *io; - guint i; + struct fuzzy_cmd_io *io, *cur; + guint i, j; GPtrArray *res; res = g_ptr_array_sized_new (task->parts->len + 1); @@ -2319,8 +2319,21 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule, io = fuzzy_cmd_from_text_part (rule, c, flag, value, task->task_pool, part); + if (io) { - g_ptr_array_add (res, io); + gboolean skip_existing = FALSE; + + PTR_ARRAY_FOREACH (res, j, cur) { + if (memcmp (cur->cmd.digest, io->cmd.digest, + sizeof (io->cmd.digest)) == 0) { + skip_existing = TRUE; + break; + } + } + + if (!skip_existing) { + g_ptr_array_add (res, io); + } } } } |