]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Sync stamps weren't updated always from header.
authorTimo Sirainen <tss@iki.fi>
Mon, 20 Oct 2003 03:24:40 +0000 (06:24 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 20 Oct 2003 03:24:40 +0000 (06:24 +0300)
--HG--
branch : HEAD

src/lib-index/mail-index.c

index c4b4ec17910592c589e34b8d15129f8854a6cdea..3c3cc19265511d4f8ce860fdbc27e05b38dfc518 100644 (file)
 #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 @@ static int mmap_verify(struct mail_index *index)
        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 @@ static int mmap_verify(struct mail_index *index)
        }
 
        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 @@ int mail_index_mmap_update(struct mail_index *index)
 
        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,