Skip to content

Commit

Permalink
lib-index: Added header-size asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Jun 14, 2016
1 parent 8faaab5 commit 8c8d706
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib-index/mail-index-map-read.c
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/lib-index/mail-index-modseq.c
Expand Up @@ -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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib-index/mail-index-sync-ext.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/lib-index/mail-index-sync-keywords.c
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/lib-index/mail-index-sync-update.c
Expand Up @@ -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)) {
Expand Down

0 comments on commit 8c8d706

Please sign in to comment.