]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Fix potential assert-crash when reconnecting during syncing
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 16 Jun 2018 16:37:27 +0000 (19:37 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 18 Jun 2018 19:10:12 +0000 (19:10 +0000)
Fixes:
Panic: file imapc-sync.c: line 328 (imapc_initial_sync_check): assertion failed: (mail_index_is_expunged(view, lseq) || seq_range_exists(&ctx->mbox->delayed_expunged_uids, luid))

src/lib-storage/index/imapc/imapc-storage.c
src/lib-storage/index/imapc/imapc-sync.c

index d7b5ba185d0fed0f67e4ade9dae711208a2da2ca..552c5d05ad82bb7d2b9b7f7dac7c1edadb4a8978 100644 (file)
@@ -628,6 +628,7 @@ static void imapc_mailbox_reopen(void *context)
                mbox->sync_next_rseq = 1;
        }
 
+       mbox->state_fetched_success = FALSE;
        mbox->initial_sync_done = FALSE;
        mbox->selecting = TRUE;
        mbox->selected = FALSE;
index 626ffc10d627c070a40d11d203197a7a8aef65e9..1ac2c552edec99d06702b04f959490ab0b97fe0b 100644 (file)
@@ -411,6 +411,12 @@ static void imapc_sync_index(struct imapc_sync_context *ctx)
                imapc_mailbox_run(mbox);
        array_free(&ctx->expunged_uids);
 
+       if (!mbox->state_fetched_success) {
+               /* All the sync commands succeeded, but we got disconnected.
+                  imapc_initial_sync_check() will crash if we go there. */
+               ctx->failed = TRUE;
+       }
+
        /* add uidnext & highestmodseq after all appends */
        imapc_sync_uid_next(ctx);
        imapc_sync_highestmodseq(ctx);