]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add the same duplicates protection for all fuzzy hashes types
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 27 May 2017 22:45:24 +0000 (23:45 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 27 May 2017 22:45:24 +0000 (23:45 +0100)
src/plugins/fuzzy_check.c

index a63201bd3105bccc82940f932d96cb0dbfd76a5e..ab326f0fe9b560e2d69ae98a1410016d5f701f23 100644 (file)
@@ -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);
                                        }
                                }