Browse files

lib-mail: Fixed message_parser_init_from_parts() with truncated MIME …

  • Loading branch information...
sirainen committed Jun 11, 2016
1 parent 20faa69 commit 1bc6f1c54b4d77830288b8cf19060bd8a6db7b27
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/lib-mail/message-parser.c
@@ -1006,14 +1006,22 @@ static int preparsed_parse_next_header(struct message_parser_ctx *ctx,
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 -

/* 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);

ctx->parse_next_block = preparsed_parse_next_header;
return preparsed_parse_next_header(ctx, block_r);

0 comments on commit 1bc6f1c

Please sign in to comment.