]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm deduplicate: Allocate memory properly for keys in hash table
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 13 Jun 2022 06:56:13 +0000 (09:56 +0300)
committerMarkus Valentin <markus.valentin@open-xchange.com>
Mon, 13 Jun 2022 10:52:13 +0000 (12:52 +0200)
This caused wrong mails to be deleted somewhat randomly.
Broken by 320844f50cd669b602d30210e2e5216f65d2050f

src/doveadm/doveadm-mail-deduplicate.c

index abe41559fba53b8e9a6377881f626d81f1038da7..f990287d7f30a4060b769af5ece66e3afec2e51d 100644 (file)
@@ -61,8 +61,10 @@ cmd_deduplicate_box(struct doveadm_mail_cmd_context *_ctx,
                if (key != NULL && *key != '\0') {
                        if (hash_table_lookup(hash, key) != NULL)
                                mail_expunge(mail);
-                       else
+                       else {
+                               key = p_strdup(pool, key);
                                hash_table_insert(hash, key, POINTER_CAST(1));
+                       }
                }
        }