]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Fix assert-crash in COPY/MOVE when storage doesn't return UIDs
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 11 Jun 2020 09:59:14 +0000 (12:59 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 11 Jun 2020 12:37:26 +0000 (15:37 +0300)
For example copying mails into virtual storage crashed.

Broken by 09413e35f764a2898cbc26cea94218eed6df5cbf

Fixes:
Panic: file cmd-copy.c: line 152 (fetch_and_copy): assertion failed: (copy_ctx->copy_count == seq_range_count(&copy_ctx->saved_uids))

src/imap/cmd-copy.c

index 593434fc5d9afc550b5635eedb06e21523ec1604..64d5af833c03d6b70ad9bbd31c39749a087d3fb4 100644 (file)
@@ -140,6 +140,11 @@ static int fetch_and_copy(struct cmd_copy_context *copy_ctx,
                if (changes.no_read_perm)
                        copy_ctx->hide_saved_uids = TRUE;
 
+               if (seq_range_count(&changes.saved_uids) == 0) {
+                       /* storage doesn't support returning UIDs */
+                       copy_ctx->hide_saved_uids = TRUE;
+               }
+
                if (copy_ctx->uid_validity == 0)
                        copy_ctx->uid_validity = changes.uid_validity;
                else if (copy_ctx->uid_validity != changes.uid_validity) {
@@ -149,7 +154,8 @@ static int fetch_and_copy(struct cmd_copy_context *copy_ctx,
                seq_range_array_merge(&copy_ctx->src_uids, &src_uids);
                seq_range_array_merge(&copy_ctx->saved_uids, &changes.saved_uids);
 
-               i_assert(copy_ctx->copy_count == seq_range_count(&copy_ctx->saved_uids));
+               i_assert(copy_ctx->copy_count == seq_range_count(&copy_ctx->saved_uids) ||
+                        copy_ctx->hide_saved_uids);
                copy_update_trashed(client, copy_ctx->destbox, copy_ctx->copy_count);
                pool_unref(&changes.pool);
        }