From: Timo Sirainen Date: Fri, 9 Oct 2020 11:58:54 +0000 (+0300) Subject: lib-storage: Fix potential assert-crash when adding missing attachment keywords X-Git-Tag: 2.3.13~103 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=787cc98cf8eca4ddc80d315a997198d0d9e449de;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fix potential assert-crash when adding missing attachment keywords Broken by aab71c35259f542d9ba46b4b5b24eff0016b802e Fixes: Panic: file index-mail.c: line 1241 (index_mail_parse_body): assertion failed: (data->parser_ctx != NULL) --- diff --git a/src/lib-storage/index/index-mail-headers.c b/src/lib-storage/index/index-mail-headers.c index 7e2088fc36..eb9695f53b 100644 --- a/src/lib-storage/index/index-mail-headers.c +++ b/src/lib-storage/index/index-mail-headers.c @@ -447,7 +447,8 @@ int index_mail_parse_headers_internal(struct index_mail *mail, index_mail_parse_header_init(mail, headers); - if (data->parts == NULL || data->save_bodystructure_header) { + if (data->parts == NULL || data->save_bodystructure_header || + (data->access_part & PARSE_BODY) != 0) { /* initialize bodystructure parsing in case we read the whole message. */ index_mail_init_parser(mail); diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 830dca558a..e7919ac6dc 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -1327,7 +1327,7 @@ int index_mail_init_stream(struct index_mail *mail, if (hdr_size != NULL || body_size != NULL || want_attachment_kw) { i_stream_seek(data->stream, 0); if (!data->hdr_size_set || want_attachment_kw) { - if ((data->access_part & PARSE_HDR) != 0) { + if ((data->access_part & (PARSE_HDR | PARSE_BODY)) != 0) { (void)get_cached_parts(mail); if (index_mail_parse_headers_internal(mail, NULL) < 0) return -1;