]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Give a better error message if transction log file shrinks unexpectedly.
authorTimo Sirainen <tss@iki.fi>
Fri, 14 May 2010 14:18:03 +0000 (16:18 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 14 May 2010 14:18:03 +0000 (16:18 +0200)
--HG--
branch : HEAD

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

index 9d7c2f4a50db09402d5dc35b1be3a5676d2ab976..a6adeebe08dd79a84d56fc234e6859011bf25778 100644 (file)
@@ -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);