From: Timo Sirainen Date: Thu, 19 Oct 2017 11:39:01 +0000 (+0300) Subject: lib-storage: Fix assert-crash when searching header and MIMEPART X-Git-Tag: 2.2.34~268 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6207b9633780dcbc253c7f065c05740351a04e48;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fix assert-crash when searching header and MIMEPART For now this is just a bit kludgy workaround. The proper fix requires larger changes, which aren't worth the effort right now. For example: doveadm fetch -u testuser uid MAILBOX inbox FROM foo MIMEPART FILENAME CONTAINS bar BODY baz Crashes with: Panic: file index-mail-headers.c: line 294 (index_mail_parse_header): assertion failed: (part != NULL) --- diff --git a/src/lib-storage/index/index-search.c b/src/lib-storage/index/index-search.c index 4a1edd951d..b860fa4d9e 100644 --- a/src/lib-storage/index/index-search.c +++ b/src/lib-storage/index/index-search.c @@ -768,7 +768,17 @@ static int search_arg_match_text(struct mail_search_arg *args, search_cur_mail_failed(ctx); failed = TRUE; } else { + /* FIXME: The header parsing here is an optimization to + avoid parsing the header twice: First when checking + whether the search matches, and secondly when + generating wanted fields. However, if we already + know that we want to generate a BODYSTRUCTURE reply, + index_mail_parse_header() must have a non-NULL part + parameter. That's not easily possible at this point + without larger code changes, so for now we'll just + disable this optimization for that case. */ hdr_ctx.parse_headers = + !hdr_ctx.imail->data.save_bodystructure_header && index_mail_want_parse_headers(hdr_ctx.imail); if (hdr_ctx.parse_headers) { index_mail_parse_header_init(hdr_ctx.imail,