Mercurial > dovecot > core-2.2
changeset 15266:99965e11d9e1
lib-storage: Check and log stream errors when parsing/searching messages.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 29 Oct 2012 13:23:30 +0200 |
parents | 41018c6fcc53 |
children | b5a5f5139148 |
files | src/lib-storage/index/index-mail-headers.c src/lib-storage/index/index-mail.c src/lib-storage/index/index-mail.h src/lib-storage/index/index-search.c |
diffstat | 4 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail-headers.c Mon Oct 29 13:01:37 2012 +0200 +++ b/src/lib-storage/index/index-mail-headers.c Mon Oct 29 13:23:30 2012 +0200 @@ -430,6 +430,8 @@ hdr_parser_flags, index_mail_parse_header_cb, mail); } + if (index_mail_stream_check_failure(mail) < 0) + return -1; data->hdr_size_set = TRUE; data->access_part &= ~PARSE_HDR; @@ -475,15 +477,17 @@ mailbox_header_lookup_unref(&header_ctx); return -1; } + mailbox_header_lookup_unref(&header_ctx); if (mail->data.envelope == NULL && stream != NULL) { /* we got the headers from cache - parse them to get the envelope */ message_parse_header(stream, NULL, hdr_parser_flags, imap_envelope_parse_callback, mail); + if (index_mail_stream_check_failure(mail) < 0) + return -1; mail->data.save_envelope = FALSE; } - mailbox_header_lookup_unref(&header_ctx); if (mail->data.stream != NULL) i_stream_seek(mail->data.stream, old_offset);
--- a/src/lib-storage/index/index-mail.c Mon Oct 29 13:01:37 2012 +0200 +++ b/src/lib-storage/index/index-mail.c Mon Oct 29 13:23:30 2012 +0200 @@ -811,7 +811,7 @@ return 0; } -static int index_mail_stream_check_failure(struct index_mail *mail) +int index_mail_stream_check_failure(struct index_mail *mail) { if (mail->data.stream->stream_errno == 0) return 0;
--- a/src/lib-storage/index/index-mail.h Mon Oct 29 13:01:37 2012 +0200 +++ b/src/lib-storage/index/index-mail.h Mon Oct 29 13:23:30 2012 +0200 @@ -223,6 +223,7 @@ void index_mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field); int index_mail_opened(struct mail *mail, struct istream **stream); +int index_mail_stream_check_failure(struct index_mail *mail); struct index_mail *index_mail_get_index_mail(struct mail *mail); bool index_mail_get_cached_uoff_t(struct index_mail *mail,
--- a/src/lib-storage/index/index-search.c Mon Oct 29 13:01:37 2012 +0200 +++ b/src/lib-storage/index/index-search.c Mon Oct 29 13:23:30 2012 +0200 @@ -626,6 +626,10 @@ ret = message_search_msg(msg_search_ctx, ctx->input, NULL); i_assert(ret >= 0 || ctx->input->stream_errno != 0); } + if (ctx->input->stream_errno != 0) { + mail_storage_set_critical(ctx->index_ctx->box->storage, + "read(%s) failed: %m", i_stream_get_name(ctx->input)); + } ARG_SET_RESULT(arg, ret); } @@ -686,6 +690,11 @@ } message_parse_header(input, NULL, hdr_parser_flags, search_header, &hdr_ctx); + if (input->stream_errno != 0) { + mail_storage_set_critical(ctx->box->storage, + "read(%s) failed: %m", i_stream_get_name(input)); + failed = TRUE; + } } } if (headers_ctx != NULL)