From: Timo Sirainen Date: Fri, 8 Apr 2022 10:42:55 +0000 (+0300) Subject: lib-index: Handle 0-sized dovecot.index.log record properly X-Git-Tag: 2.3.19~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=40e2a21f83fb11cd36e109b93d2b3fd704e3536e;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Handle 0-sized dovecot.index.log record properly The previous behavior was to just silently ignore it and have the next write to the transaction log silently truncate away the trailing garbage. Now if the log file isn't locked the issue is still ignored, since it's possible that this is just a race condition. But if the log is locked, it's handled as corruption. --- diff --git a/src/lib-index/mail-transaction-log-file.c b/src/lib-index/mail-transaction-log-file.c index 753cb65c76..18201692bf 100644 --- a/src/lib-index/mail-transaction-log-file.c +++ b/src/lib-index/mail-transaction-log-file.c @@ -1188,8 +1188,8 @@ mail_transaction_log_file_sync(struct mail_transaction_log_file *file, file->buffer_offset); trans_size = mail_index_offset_to_uint32(hdr->size); if (trans_size == 0) { - /* unfinished */ - return 1; + /* unfinished or corrupted */ + break; } if (trans_size < sizeof(*hdr)) { *reason_r = t_strdup_printf(