dovecot-2.2: lib-storage: Fixed assert-crash when BODYSTRUCTURE ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Oct 7 17:29:50 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/2b84c33d5d11
changeset: 17909:2b84c33d5d11
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Oct 07 20:29:16 2014 +0300
description:
lib-storage: Fixed assert-crash when BODYSTRUCTURE parsing fails due to broken mail size.

diffstat:

 src/lib-storage/index/index-mail.c |  26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diffs (36 lines):

diff -r 64e59ebcfe25 -r 2b84c33d5d11 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Tue Oct 07 20:28:06 2014 +0300
+++ b/src/lib-storage/index/index-mail.c	Tue Oct 07 20:29:16 2014 +0300
@@ -847,17 +847,21 @@
 		i_stream_ref(parser_input);
 		ret = message_parser_deinit(&mail->data.parser_ctx,
 					    &mail->data.parts) < 0 ? 0 : 1;
-		if (parser_input->stream_errno == 0 ||
-		    parser_input->stream_errno == EPIPE) {
-			/* EPIPE = input already closed. allow the caller to
-			   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.) */
-			i_assert(!success ||
-				 (i_stream_read(parser_input) == -1 &&
-				  !i_stream_have_bytes_left(parser_input)));
-		} else {
+		if (success && (parser_input->stream_errno == 0 ||
+				parser_input->stream_errno == EPIPE)) {
+			/* do one final read, which verifies that the message
+			   size is correct. */
+			if (i_stream_read(parser_input) != -1 ||
+			    i_stream_have_bytes_left(parser_input))
+				i_unreached();
+		}
+		/* EPIPE = input already closed. allow the caller to
+		   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) {
 			index_mail_stream_log_failure_for(mail, parser_input);
 			ret = -1;
 		}


More information about the dovecot-cvs mailing list