static int preparsed_parse_next_header_init(struct message_parser_ctx *ctx,
struct message_block *block_r)
{
+ struct istream *hdr_input;
+
i_assert(ctx->hdr_parser_ctx == NULL);
i_assert(ctx->part->physical_pos >= ctx->input->v_offset);
i_stream_skip(ctx->input, ctx->part->physical_pos -
ctx->input->v_offset);
+ /* the header may become truncated by --boundaries. limit the header
+ stream's size to what it's supposed to be to avoid duplicating (and
+ keeping in sync!) all the same complicated logic as in
+ parse_next_header(). */
+ hdr_input = i_stream_create_limit(ctx->input, ctx->part->header_size.physical_size);
ctx->hdr_parser_ctx =
- message_parse_header_init(ctx->input, NULL, ctx->hdr_flags);
+ message_parse_header_init(hdr_input, NULL, ctx->hdr_flags);
+ i_stream_unref(&hdr_input);
ctx->parse_next_block = preparsed_parse_next_header;
return preparsed_parse_next_header(ctx, block_r);