changeset 9568:46d3128626b7 HEAD

lib-index: Give a better error message if transction log file shrinks unexpectedly.
author Timo Sirainen <tss@iki.fi>
date Fri, 14 May 2010 16:18:03 +0200
parents 2cdfcca171d8
children 2129667cb499
files src/lib-index/mail-transaction-log-file.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log-file.c	Mon May 10 11:05:58 2010 +0300
+++ b/src/lib-index/mail-transaction-log-file.c	Fri May 14 16:18:03 2010 +0200
@@ -1135,6 +1135,12 @@
 	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);