dovecot-2.2: lib-storage: BODYSTRUCTURE parsing failures weren't...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jun 26 14:52:54 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/5c2bc165c5e9
changeset: 17519:5c2bc165c5e9
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jun 26 17:50:57 2014 +0300
description:
lib-storage: BODYSTRUCTURE parsing failures weren't treated correctly.
We still assumed that the parsing succeeded and assert-crashed later or
maybe returned invalid results. (This could have happened only if there was
a problem reading the mail stream.)

diffstat:

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

diffs (47 lines):

diff -r 25326be366c5 -r 5c2bc165c5e9 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Thu Jun 26 17:27:31 2014 +0300
+++ b/src/lib-storage/index/index-mail.c	Thu Jun 26 17:50:57 2014 +0300
@@ -684,6 +684,7 @@
 
 	if (!data->parsed_bodystructure)
 		return;
+	i_assert(data->parts != NULL);
 
 	/* If BODY is fetched first but BODYSTRUCTURE is also wanted, we don't
 	   normally want to first cache BODY and then BODYSTRUCTURE. So check
@@ -921,8 +922,6 @@
 		message_parser_parse_body(data->parser_ctx,
 					  parse_bodystructure_part_header,
 					  mail->mail.data_pool);
-		data->save_bodystructure_body = FALSE;
-		data->parsed_bodystructure = TRUE;
 	} else {
 		message_parser_parse_body(data->parser_ctx,
 			*null_message_part_header_callback, (void *)NULL);
@@ -930,6 +929,11 @@
 	ret = index_mail_stream_check_failure(mail);
 	if (index_mail_parse_body_finish(mail, field, TRUE) < 0)
 		ret = -1;
+	if (ret == 0 && data->save_bodystructure_body) {
+		data->save_bodystructure_body = FALSE;
+		data->parsed_bodystructure = TRUE;
+		i_assert(data->parts != NULL);
+	}
 
 	i_stream_seek(data->stream, old_offset);
 	return ret;
@@ -1726,9 +1730,11 @@
 		mail->data.save_date = ioloop_time;
 	}
 
-	mail->data.save_bodystructure_body = FALSE;
-	mail->data.parsed_bodystructure = TRUE;
-	(void)index_mail_parse_body_finish(mail, 0, success);
+	if (index_mail_parse_body_finish(mail, 0, success) == 0) {
+		mail->data.save_bodystructure_body = FALSE;
+		mail->data.parsed_bodystructure = TRUE;
+		i_assert(mail->data.parts != NULL);
+	}
 }
 
 static void index_mail_drop_recent_flag(struct mail *mail)


More information about the dovecot-cvs mailing list