]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix potential assert-crash when adding missing attachment keywords
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 9 Oct 2020 11:58:54 +0000 (14:58 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 9 Oct 2020 12:09:45 +0000 (15:09 +0300)
Broken by aab71c35259f542d9ba46b4b5b24eff0016b802e

Fixes:
Panic: file index-mail.c: line 1241 (index_mail_parse_body): assertion failed: (data->parser_ctx != NULL)

src/lib-storage/index/index-mail-headers.c
src/lib-storage/index/index-mail.c

index 7e2088fc3616c28741f81d9776713f11ebda55e1..eb9695f53b6f5a27d3fa4db5219bad69de4e1236 100644 (file)
@@ -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);
index 830dca558a5812146ed1d86bc91ea857c812a5e4..e7919ac6dc9f9f7483feeb8f0e970378f4722ebb 100644 (file)
@@ -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;