From: Timo Sirainen Date: Fri, 3 Jun 2016 17:00:14 +0000 (+0300) Subject: lib-index: Added header-size asserts X-Git-Tag: 2.2.25.rc1~189 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c8d70670208914dee3d0adff4b735e0e7da16c4;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Added header-size asserts --- diff --git a/src/lib-index/mail-index-map-read.c b/src/lib-index/mail-index-map-read.c index 7081f8c0f3..e84c4b70c8 100644 --- a/src/lib-index/mail-index-map-read.c +++ b/src/lib-index/mail-index-map-read.c @@ -238,6 +238,7 @@ mail_index_try_read_map(struct mail_index_map *map, mail_index_map_copy_hdr(map, hdr); map->hdr_base = map->hdr_copy_buf->data; + i_assert(map->hdr_copy_buf->used == map->hdr.header_size); return 1; } diff --git a/src/lib-index/mail-index-modseq.c b/src/lib-index/mail-index-modseq.c index 1d7c9ba319..29ceb585d5 100644 --- a/src/lib-index/mail-index-modseq.c +++ b/src/lib-index/mail-index-modseq.c @@ -521,6 +521,7 @@ static void mail_index_modseq_update_header(struct mail_index_view *view, buffer_write(map->hdr_copy_buf, ext->hdr_offset, &new_modseq_hdr, sizeof(new_modseq_hdr)); map->hdr_base = map->hdr_copy_buf->data; + i_assert(map->hdr_copy_buf->used == map->hdr.header_size); } } diff --git a/src/lib-index/mail-index-sync-ext.c b/src/lib-index/mail-index-sync-ext.c index 994a2331ac..19beb8cc3f 100644 --- a/src/lib-index/mail-index-sync-ext.c +++ b/src/lib-index/mail-index-sync-ext.c @@ -570,6 +570,7 @@ static void mail_index_sync_ext_clear(struct mail_index_view *view, memset(buffer_get_space_unsafe(map->hdr_copy_buf, ext->hdr_offset, ext->hdr_size), 0, ext->hdr_size); map->hdr_base = map->hdr_copy_buf->data; + i_assert(map->hdr_copy_buf->used == map->hdr.header_size); for (seq = 1; seq <= view->map->rec_map->records_count; seq++) { rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq); @@ -640,6 +641,7 @@ int mail_index_sync_ext_hdr_update(struct mail_index_sync_map_ctx *ctx, buffer_write(map->hdr_copy_buf, ext->hdr_offset + offset, data, size); map->hdr_base = map->hdr_copy_buf->data; + i_assert(map->hdr_copy_buf->used == map->hdr.header_size); if (ext->index_idx == ctx->view->index->modseq_ext_id) mail_index_modseq_hdr_update(ctx->modseq_ctx); diff --git a/src/lib-index/mail-index-sync-keywords.c b/src/lib-index/mail-index-sync-keywords.c index 8546310038..7d5d0964f6 100644 --- a/src/lib-index/mail-index-sync-keywords.c +++ b/src/lib-index/mail-index-sync-keywords.c @@ -190,6 +190,7 @@ keywords_header_add(struct mail_index_sync_map_ctx *ctx, buffer_copy(map->hdr_copy_buf, ext->hdr_offset, buf, 0, buf->used); map->hdr_base = map->hdr_copy_buf->data; + i_assert(map->hdr_copy_buf->used == map->hdr.header_size); if (mail_index_map_parse_keywords(map) < 0) i_panic("Keyword update corrupted keywords header"); diff --git a/src/lib-index/mail-index-sync-update.c b/src/lib-index/mail-index-sync-update.c index bb35a29fb6..0e0edee624 100644 --- a/src/lib-index/mail-index-sync-update.c +++ b/src/lib-index/mail-index-sync-update.c @@ -496,6 +496,7 @@ static int sync_header_update(const struct mail_transaction_header_update *u, buffer_write(map->hdr_copy_buf, u->offset, u + 1, u->size); map->hdr_base = map->hdr_copy_buf->data; + i_assert(map->hdr_copy_buf->used == map->hdr.header_size); /* @UNSAFE */ if ((uint32_t)(u->offset + u->size) <= sizeof(map->hdr)) {