diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:32:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:32:03 +0000 |
commit | a7ef3cd3c7d32e8799ad0a397fc57e8c347463cf (patch) | |
tree | bf1501b7b11bd1ca1c7b4b4df5be689e1f7c750f /src/lib-mail/message-parser.c | |
parent | Releasing progress-linux version 1:2.3.21+dfsg1-3~progress7.99u1. (diff) | |
download | dovecot-a7ef3cd3c7d32e8799ad0a397fc57e8c347463cf.tar.xz dovecot-a7ef3cd3c7d32e8799ad0a397fc57e8c347463cf.zip |
Merging upstream version 1:2.3.21.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib-mail/message-parser.c')
-rw-r--r-- | src/lib-mail/message-parser.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib-mail/message-parser.c b/src/lib-mail/message-parser.c index 9a9c9a3..c7e3b1e 100644 --- a/src/lib-mail/message-parser.c +++ b/src/lib-mail/message-parser.c @@ -617,7 +617,18 @@ static int parse_next_header(struct message_parser_ctx *ctx, } if (ret < 0) { /* no boundary */ + size_t headers_available = + ctx->all_headers_max_size > ctx->all_headers_total_size ? + ctx->all_headers_max_size - ctx->all_headers_total_size : 0; + message_parse_header_lower_limit(ctx->hdr_parser_ctx, headers_available); ret = message_parse_header_next(ctx->hdr_parser_ctx, &hdr); + if (ret > 0) { + if (!hdr->continues) { + ctx->all_headers_total_size += hdr->name_len; + ctx->all_headers_total_size += hdr->middle_len; + } + ctx->all_headers_total_size += hdr->value_len; + } if (ret == 0 || (ret < 0 && ctx->input->stream_errno != 0)) { ctx->want_count = i_stream_get_data_size(ctx->input) + 1; return ret; @@ -762,6 +773,9 @@ message_parser_init_int(struct istream *input, ctx->max_total_mime_parts = set->max_total_mime_parts != 0 ? set->max_total_mime_parts : MESSAGE_PARSER_DEFAULT_MAX_TOTAL_MIME_PARTS; + ctx->all_headers_max_size = set->all_headers_max_size != 0 ? + set->all_headers_max_size : + MESSAGE_PARSER_DEFAULT_ALL_HEADERS_MAX_SIZE; ctx->input = input; i_stream_ref(input); return ctx; @@ -779,6 +793,7 @@ message_parser_init(pool_t part_pool, struct istream *input, ctx->next_part = &ctx->part->children; ctx->parse_next_block = parse_next_header_init; ctx->total_parts_count = 1; + ctx->all_headers_total_size = 0; i_array_init(&ctx->next_part_stack, 4); return ctx; } |