Mercurial > dovecot > core-2.2
changeset 17909:2b84c33d5d11
lib-storage: Fixed assert-crash when BODYSTRUCTURE parsing fails due to broken mail size.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 07 Oct 2014 20:29:16 +0300 |
parents | 64e59ebcfe25 |
children | 96f79038038f |
files | src/lib-storage/index/index-mail.c |
diffstat | 1 files changed, 15 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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; }