]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Fix assert-crash when header's log_file_seq/offset shrinks
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 2 Jan 2023 08:23:43 +0000 (10:23 +0200)
committerDovecot Automation <automation@dovecot.org>
Thu, 30 Mar 2023 08:30:44 +0000 (10:30 +0200)
mail_index_sync_set_log_view() is also missing this check, but it doesn't
seem to actually happen. It's likely handled by mail_index_map() already.

Fixes:
Panic: file mail-transaction-log-view.c: line 165 (mail_transaction_log_view_set): assertion failed: (min_file_seq <= max_file_seq)

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

index 6322ee18690f803bd612ab2388894d463e5e0692..c847f1cc01f7eb966c2f700a79620708a4e57ae0 100644 (file)
@@ -544,6 +544,12 @@ static bool mail_index_sync_view_have_any(struct mail_index_view *view,
                return TRUE;
 
        mail_transaction_log_get_head(view->index->log, &log_seq, &log_offset);
+       if (log_seq < view->map->hdr.log_file_seq ||
+           ((log_seq == view->map->hdr.log_file_seq &&
+             log_offset < view->map->hdr.log_file_tail_offset))) {
+               /* invalid offsets - let the syncing handle the error */
+               return TRUE;
+       }
        if (mail_transaction_log_view_set(view->log_view,
                                          view->map->hdr.log_file_seq,
                                          view->map->hdr.log_file_tail_offset,