From: Timo Sirainen Date: Fri, 11 Oct 2019 11:53:26 +0000 (+0300) Subject: lib-storage: Fix potential assert-crash fetching BODY[STRUCTURE] when mail's size... X-Git-Tag: 2.3.14.rc1~210 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5dc69d900a7695947f18e64e2b7e30bd6cb91a6c;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fix potential assert-crash fetching BODY[STRUCTURE] when mail's size is cached wrong 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) --- diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index a362942910..62dd4e03b2 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -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; }