From: Timo Sirainen Date: Mon, 2 Jan 2023 08:23:43 +0000 (+0200) Subject: lib-index: Fix assert-crash when header's log_file_seq/offset shrinks X-Git-Tag: 2.3.21~99 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c29eccb64e5d9f9076601e95e7844361aa9b2d7f;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Fix assert-crash when header's log_file_seq/offset shrinks 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) --- diff --git a/src/lib-index/mail-index-sync.c b/src/lib-index/mail-index-sync.c index 6322ee1869..c847f1cc01 100644 --- a/src/lib-index/mail-index-sync.c +++ b/src/lib-index/mail-index-sync.c @@ -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,