]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix potential assert-crash fetching BODY[STRUCTURE] when mail's size...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 11 Oct 2019 11:53:26 +0000 (14:53 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 16 Dec 2020 11:02:40 +0000 (11:02 +0000)
This happened only after mail's size was detected to be different than the
mail's cached size.

Fixes:
Panic: file index-mail.c: line 1140 (index_mail_parse_body_finish): assertion failed: (mail->data.parts != NULL)

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

index a3629429108b47b04acec27eac327f528e5301f5..62dd4e03b256c718fb655a0d5c3b53cae89c4aa7 100644 (file)
@@ -1143,9 +1143,15 @@ index_mail_parse_body_finish(struct index_mail *mail,
                   decide if that is an error or not. (for example we
                   could be coming here from IMAP APPEND when IMAP
                   client has closed the connection too early. we
-                  don't want to log an error in that case.) */
-               if (parser_input->stream_errno != 0 &&
-                   parser_input->stream_errno != EPIPE) {
+                  don't want to log an error in that case.)
+                  Note that EPIPE may also come from istream-mail which
+                  detects a corrupted message size. Either way, the
+                  body wasn't successfully parsed. */
+               if (parser_input->stream_errno == 0)
+                       ;
+               else if (parser_input->stream_errno == EPIPE)
+                       ret = -1;
+               else {
                        index_mail_stream_log_failure_for(mail, parser_input);
                        ret = -1;
                }