diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-27 23:45:24 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-27 23:45:24 +0100 |
commit | 845839e71caa234ab680d4ec09f5051b4d9615e3 (patch) | |
tree | 709b7ee020d43a5ec64cfebfb65f2ffe9259ceee /src/plugins/fuzzy_check.c | |
parent | 47b87877734ceea722d42ee9c92f727332e40a92 (diff) | |
download | rspamd-845839e71caa234ab680d4ec09f5051b4d9615e3.tar.gz rspamd-845839e71caa234ab680d4ec09f5051b4d9615e3.zip |
[Minor] Add the same duplicates protection for all fuzzy hashes types
Diffstat (limited to 'src/plugins/fuzzy_check.c')
-rw-r--r-- | src/plugins/fuzzy_check.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index a63201bd3..ab326f0fe 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -2357,6 +2357,20 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule, task->task_pool, image->parent->digest); if (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); + } + g_ptr_array_add (res, io); } @@ -2372,6 +2386,20 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule, task->task_pool, image); if (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); + } + g_ptr_array_add (res, io); } } @@ -2394,6 +2422,20 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule, task->task_pool, mime_part->digest); if (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); + } + g_ptr_array_add (res, io); } } |