From: Timo Sirainen Date: Fri, 14 May 2010 14:18:03 +0000 (+0200) Subject: lib-index: Give a better error message if transction log file shrinks unexpectedly. X-Git-Tag: 2.0.beta6~217 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=57549c98995eb312013f5d98ea6ccf25175a6f18;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Give a better error message if transction log file shrinks unexpectedly. --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-transaction-log-file.c b/src/lib-index/mail-transaction-log-file.c index 9d7c2f4a50..a6adeebe08 100644 --- a/src/lib-index/mail-transaction-log-file.c +++ b/src/lib-index/mail-transaction-log-file.c @@ -1146,6 +1146,12 @@ mail_transaction_log_file_sync(struct mail_transaction_log_file *file) i_assert(file->sync_offset >= file->buffer_offset); data = buffer_get_data(file->buffer, &size); + if (file->buffer_offset + size < file->sync_offset) { + mail_transaction_log_file_set_corrupted(file, + "log file shrank (%"PRIuUOFF_T" < %"PRIuUOFF_T")", + file->buffer_offset + (uoff_t)size, file->sync_offset); + return -1; + } while (file->sync_offset - file->buffer_offset + sizeof(*hdr) <= size) { hdr = CONST_PTR_OFFSET(data, file->sync_offset - file->buffer_offset);