]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Added header-size asserts
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 3 Jun 2016 17:00:14 +0000 (20:00 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 14 Jun 2016 09:21:26 +0000 (12:21 +0300)
src/lib-index/mail-index-map-read.c
src/lib-index/mail-index-modseq.c
src/lib-index/mail-index-sync-ext.c
src/lib-index/mail-index-sync-keywords.c
src/lib-index/mail-index-sync-update.c

index 7081f8c0f364d3b7317bf9b4fefd385a9288c9d6..e84c4b70c8d34ea7ef44a6f6c652276ee0121324 100644 (file)
@@ -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;
 }
 
index 1d7c9ba319344a10dc2675b693da46c173ee099b..29ceb585d5304f05eeb32275127c4414eabeb4bb 100644 (file)
@@ -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);
        }
 }
 
index 994a2331ac16f71733006d98e104967f7ccfc7ab..19beb8cc3f3244de1a491e675369ba2c0dcf22b7 100644 (file)
@@ -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);
index 8546310038dbaa2a5e259775cd532cdbafc1e542..7d5d0964f694ac1498bd6ed50176026374187699 100644 (file)
@@ -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");
index bb35a29fb69b49d6cca0fa06fe18fcc59689f2e0..0e0edee624fb79783ba91f43c50d669e89b73d72 100644 (file)
@@ -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)) {