Skip to content

Commit

Permalink
imap: Fix assert-crash in COPY/MOVE when storage doesn't return UIDs
Browse files Browse the repository at this point in the history
For example copying mails into virtual storage crashed.

Broken by 09413e3

Fixes:
Panic: file cmd-copy.c: line 152 (fetch_and_copy): assertion failed: (copy_ctx->copy_count == seq_range_count(&copy_ctx->saved_uids))
  • Loading branch information
sirainen committed Jun 11, 2020
1 parent 0fb7f89 commit 203b2b7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/imap/cmd-copy.c
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 203b2b7

Please sign in to comment.