[dovecot-cvs] dovecot/src/lib-index mail-index.c,1.100,1.101

cras at procontrol.fi cras at procontrol.fi
Mon Oct 20 07:24:43 EEST 2003


Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv15561/lib-index

Modified Files:
	mail-index.c 
Log Message:
Sync stamps weren't updated always from header.



Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- mail-index.c	20 Oct 2003 03:13:06 -0000	1.100
+++ mail-index.c	20 Oct 2003 03:24:40 -0000	1.101
@@ -14,6 +14,16 @@
 #include <unistd.h>
 #include <fcntl.h>
 
+static void update_header(struct mail_index *index)
+{
+	struct mail_index_header *hdr = index->header;
+
+	index->cache_sync_id = hdr->cache_sync_id;
+	index->log_sync_id = hdr->log_sync_id;
+	index->sync_stamp = hdr->sync_stamp;
+	index->sync_size = hdr->sync_size;
+}
+
 static int mmap_verify(struct mail_index *index)
 {
 	struct mail_index_header *hdr;
@@ -31,6 +41,12 @@
 	index->header = hdr;
 	index->header_size = hdr->header_size;
 
+	if (index->header_size > index->mmap_full_length) {
+		index_set_corrupted(index, "Invalid header_size in header "
+				    "(%u)", index->header_size);
+		return FALSE;
+	}
+
 	extra = (index->mmap_full_length - index->header_size) %
 		sizeof(struct mail_index_record);
 
@@ -75,11 +91,8 @@
 	}
 
 	index->master_sync_id = hdr->master_sync_id;
-	index->cache_sync_id = hdr->cache_sync_id;
-	index->log_sync_id = hdr->log_sync_id;
-	index->sync_stamp = hdr->sync_stamp;
-	index->sync_size = hdr->sync_size;
 	index->mmap_used_length = hdr->used_file_size;
+        update_header(index);
 	return TRUE;
 }
 
@@ -90,9 +103,7 @@
 
 	if (index->mmap_base != NULL) {
 		index->header = (struct mail_index_header *) index->mmap_base;
-
-		index->cache_sync_id = index->header->cache_sync_id;
-		index->log_sync_id = index->header->log_sync_id;
+		update_header(index);
 
 		if (index->mmap_invalidate) {
 			if (msync(index->mmap_base,



More information about the dovecot-cvs mailing list