[dovecot-cvs] dovecot/src/lib-index mail-index.c,1.156,1.157

cras at dovecot.org cras at dovecot.org
Mon Oct 25 22:47:21 EEST 2004


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

Modified Files:
	mail-index.c 
Log Message:
Handle major version changes silently even if the file isn't large enough to
contain full expected header.



Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -d -r1.156 -r1.157
--- mail-index.c	25 Oct 2004 19:41:50 -0000	1.156
+++ mail-index.c	25 Oct 2004 19:47:18 -0000	1.157
@@ -356,6 +356,14 @@
 		return -1;
 	}
 
+	hdr = map->mmap_base;
+	if (map->mmap_size >
+	    offsetof(struct mail_index_header, major_version) &&
+	    hdr->major_version != MAIL_INDEX_MAJOR_VERSION) {
+		/* major version change - handle silently */
+		return 0;
+	}
+
 	if (map->mmap_size < MAIL_INDEX_HEADER_MIN_SIZE) {
 		mail_index_set_error(index, "Corrupted index file %s: "
 				     "File too small (%"PRIuSIZE_T")",
@@ -363,7 +371,6 @@
 		return 0;
 	}
 
-	hdr = map->mmap_base;
 	map->hdr = hdr;
 	map->mmap_used_size = hdr->header_size +
 		hdr->messages_count * hdr->record_size;
@@ -421,6 +428,12 @@
 			pos += ret;
 	}
 
+	if (ret > (ssize_t)offsetof(struct mail_index_header, major_version) &&
+	    hdr.major_version != MAIL_INDEX_MAJOR_VERSION) {
+		/* major version change - handle silently */
+		return 0;
+	}
+
 	if (ret >= 0 && pos >= MAIL_INDEX_HEADER_MIN_SIZE &&
 	    (ret > 0 || pos >= hdr.base_header_size)) {
 		if (hdr.base_header_size < MAIL_INDEX_HEADER_MIN_SIZE ||



More information about the dovecot-cvs mailing list