]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Fix potential crash when view is synced after index is reset
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 12 Dec 2019 10:30:37 +0000 (12:30 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 16 Dec 2019 13:10:12 +0000 (13:10 +0000)
view_sync_set_log_view_range() sees that index is reset, so it clears the
log_view, which sets log_view->cur=NULL. Later on view_sync_have_expunges()
calls mail_transaction_log_view_mark(), which crashes because
log_view->cur==NULL.

This crash mainly happened when searching for seen flags in a newly created
mailbox with INDEXPVT. This commit doesn't actually fix the bug, but it
fixes the resulting crash.

src/lib-index/mail-index-view-sync.c

index 4da205ad8b771db6a1cf97aaaa812b50f1f69cce..92ebede45f1924b7c7244102cffb16d5be92d3bf 100644 (file)
@@ -227,6 +227,9 @@ static bool view_sync_have_expunges(struct mail_index_view *view)
        bool have_expunges = FALSE;
        int ret;
 
+       if (mail_transaction_log_view_is_last(view->log_view))
+               return FALSE;
+
        mail_transaction_log_view_mark(view->log_view);
 
        while ((ret = mail_transaction_log_view_next(view->log_view,