[dovecot-cvs] dovecot/src/lib-index mail-index-sync.c,1.43,1.44

cras at dovecot.org cras at dovecot.org
Mon Dec 13 02:55:45 EET 2004


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv670/lib-index

Modified Files:
	mail-index-sync.c 
Log Message:
If log file sequences get broken, complain instead of crashing.



Index: mail-index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- mail-index-sync.c	28 Nov 2004 23:19:53 -0000	1.43
+++ mail-index-sync.c	13 Dec 2004 00:55:42 -0000	1.44
@@ -4,7 +4,7 @@
 #include "buffer.h"
 #include "mail-index-view-private.h"
 #include "mail-index-sync-private.h"
-#include "mail-transaction-log.h"
+#include "mail-transaction-log-private.h"
 #include "mail-transaction-util.h"
 #include "mail-cache.h"
 
@@ -342,6 +342,17 @@
 
 	ctx->view = mail_index_view_open(index);
 
+	if (index->hdr->log_file_seq == seq &&
+	    index->hdr->log_file_int_offset > offset) {
+		/* synced offset is greater than what we have available.
+		   the log sequences have gotten messed up. */
+		mail_transaction_log_file_set_corrupted(index->log->head,
+			"log_file_int_offset (%u) > log size (%"PRIuUOFF_T")",
+			seq, index->hdr->log_file_int_offset, offset);
+                mail_index_sync_rollback(ctx);
+		return -1;
+	}
+
 	if (mail_transaction_log_view_set(ctx->view->log_view,
 					  index->hdr->log_file_seq,
 					  index->hdr->log_file_int_offset,



More information about the dovecot-cvs mailing list