From: Timo Sirainen Date: Mon, 20 Oct 2003 03:24:40 +0000 (+0300) Subject: Sync stamps weren't updated always from header. X-Git-Tag: 1.1.alpha1~4288 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d9db95775ffa2dae26cd6914f89333b8c69ef8e;p=thirdparty%2Fdovecot%2Fcore.git Sync stamps weren't updated always from header. --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-index.c b/src/lib-index/mail-index.c index c4b4ec1791..3c3cc19265 100644 --- a/src/lib-index/mail-index.c +++ b/src/lib-index/mail-index.c @@ -14,6 +14,16 @@ #include #include +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,