Mercurial > dovecot > core-2.2
changeset 3848:5703f0516342 HEAD
Handle unexpectedly breaking mboxes better without crashing.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 11 Jan 2006 22:45:03 +0200 |
parents | 145b9742b741 |
children | 8d2028705702 |
files | src/lib-storage/index/mbox/istream-raw-mbox.c src/lib-storage/index/mbox/mbox-mail.c |
diffstat | 2 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c Wed Jan 11 22:20:52 2006 +0200 +++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Wed Jan 11 22:45:03 2006 +0200 @@ -397,6 +397,12 @@ if (rstream->hdr_offset == rstream->from_offset) (void)_read(&rstream->istream); + if (rstream->corrupted) { + i_error("Unexpectedly lost From-line at " + "%"PRIuUOFF_T, rstream->from_offset); + return (uoff_t)-1; + } + return rstream->hdr_offset; } @@ -416,8 +422,15 @@ i_stream_get_data(stream, &pos); i_stream_skip(stream, pos); - if (_read(&rstream->istream) < 0) + if (_read(&rstream->istream) < 0) { + if (rstream->corrupted) { + i_error("Unexpectedly lost From-line at " + "%"PRIuUOFF_T, rstream->from_offset); + } else { + i_assert(rstream->body_offset != (uoff_t)-1); + } break; + } } i_stream_seek(stream, offset);
--- a/src/lib-storage/index/mbox/mbox-mail.c Wed Jan 11 22:20:52 2006 +0200 +++ b/src/lib-storage/index/mbox/mbox-mail.c Wed Jan 11 22:45:03 2006 +0200 @@ -160,6 +160,8 @@ stream = mbox->mbox_stream; hdr_offset = istream_raw_mbox_get_header_offset(stream); body_offset = istream_raw_mbox_get_body_offset(stream); + if (body_offset == (uoff_t)-1) + return (uoff_t)-1; body_size = istream_raw_mbox_get_body_size(stream, (uoff_t)-1); data->physical_size = (body_offset - hdr_offset) + body_size;