]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix assert-crash when searching header and MIMEPART
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 19 Oct 2017 11:39:01 +0000 (14:39 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 24 Oct 2017 11:17:19 +0000 (14:17 +0300)
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)

src/lib-storage/index/index-search.c

index 4a1edd951dbaa7e45fdf2797c678bd5cfc174ea3..b860fa4d9edddf5f17d1288504cce7aa7958bec3 100644 (file)
@@ -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,