]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Fix assert-crash after "log file shrank" error.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 28 Nov 2016 11:04:47 +0000 (13:04 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 28 Nov 2016 11:10:25 +0000 (13:10 +0200)
Fixes:
Panic: file buffer.c: line 316 (buffer_set_used_size): assertion failed: (used_size <= buf->alloc)

src/lib-index/mail-transaction-log-file.c

index 4d24e705d1dce7c4f7858ad70d246ec6f2b4caf3..92c7496ade8dac8b4400b1f04339c84a7e0647f8 100644 (file)
@@ -1372,6 +1372,8 @@ mail_transaction_log_file_sync(struct mail_transaction_log_file *file)
                mail_transaction_log_file_set_corrupted(file,
                        "log file shrank (%"PRIuUOFF_T" < %"PRIuUOFF_T")",
                        file->buffer_offset + (uoff_t)size, file->sync_offset);
+               /* fix the sync_offset to avoid crashes later on */
+               file->sync_offset = file->buffer_offset + size;
                return -1;
        }
        while (file->sync_offset - file->buffer_offset + sizeof(*hdr) <= size) {