Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8052:ab7ad44d709a HEAD
Fixed a potential crash if message parsing failed while fetching bodystructure.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 21 Jul 2008 19:31:39 +0300 |
parents | 0cf12f30985f |
children | d8a22a7f8b08 |
files | src/lib-storage/index/index-mail.c |
diffstat | 1 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail.c Mon Jul 21 18:18:27 2008 +0300 +++ b/src/lib-storage/index/index-mail.c Mon Jul 21 19:31:39 2008 +0300 @@ -710,20 +710,21 @@ (void)index_mail_cache_sent_date(mail); } -static void index_mail_parse_body_finish(struct index_mail *mail, - enum index_cache_field field) +static int index_mail_parse_body_finish(struct index_mail *mail, + enum index_cache_field field) { if (message_parser_deinit(&mail->data.parser_ctx, &mail->data.parts) < 0) { mail_set_cache_corrupted(&mail->mail.mail, MAIL_FETCH_MESSAGE_PARTS); - return; + mail->data.parsed_bodystructure = FALSE; + return -1; } if (mail->data.no_caching) { /* if we're here because we aborted parsing, don't get any further or we may crash while generating output from incomplete data */ - return; + return 0; } (void)get_cached_msgpart_sizes(mail); @@ -733,6 +734,7 @@ index_mail_body_parsed_cache_bodystructure(mail, field); index_mail_cache_sizes(mail); index_mail_cache_dates(mail); + return 0; } static int index_mail_stream_check_failure(struct index_mail *mail) @@ -772,7 +774,8 @@ null_message_part_header_callback, NULL); } ret = index_mail_stream_check_failure(mail); - index_mail_parse_body_finish(mail, field); + if (index_mail_parse_body_finish(mail, field) < 0) + ret = -1; i_stream_seek(data->stream, old_offset); return ret; @@ -871,6 +874,8 @@ if (index_mail_parse_body(mail, field) < 0) return -1; } + i_assert(data->parts != NULL); + /* if we didn't want to have the body(structure) cached, it's still not written. */ switch (field) { @@ -1360,7 +1365,7 @@ mail->data.save_bodystructure_body = FALSE; mail->data.parsed_bodystructure = TRUE; - index_mail_parse_body_finish(mail, 0); + (void)index_mail_parse_body_finish(mail, 0); } void index_mail_update_flags(struct mail *mail, enum modify_type modify_type,