Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8353:9873654f9c48 HEAD
mbox: If Content-Length: is correct, don't break if message body begins with a From_-line.
Based on a patch by Lennart Lövstrand.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 29 Oct 2008 20:01:39 +0200 |
parents | 1dc1f8163166 |
children | 5339d2ebeb56 |
files | src/lib-storage/index/mbox/istream-raw-mbox.c |
diffstat | 1 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c Wed Oct 29 18:41:56 2008 +0200 +++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Wed Oct 29 20:01:39 2008 +0200 @@ -504,7 +504,7 @@ (struct raw_mbox_istream *)stream->real_stream; const unsigned char *data; size_t size; - uoff_t old_offset, body_size; + uoff_t old_offset, body_size, next_body_offset; i_assert(rstream->hdr_offset != (uoff_t)-1); i_assert(rstream->body_offset != (uoff_t)-1); @@ -520,11 +520,21 @@ if (body_size != (uoff_t)-1 && body_size >= expected_body_size) return body_size; - i_stream_seek(rstream->istream.parent, - rstream->body_offset + expected_body_size); + next_body_offset = rstream->body_offset + expected_body_size; + /* If the body_size is zero but the expected_body_size is + non-zero, that means that the first line of the message's + body is likely a From_-line and that the body_offset is + pointing to the line *before* the first line of the body, + i.e. the empty line separating the headers from the body. + If that is the case, we'll have to skip over the empty + line to get the correct next_body_offset. */ + if (body_size == 0) + next_body_offset += rstream->crlf_ending ? 2 : 1; + + i_stream_seek(rstream->istream.parent, next_body_offset); if (istream_raw_mbox_is_valid_from(rstream) > 0) { - rstream->mail_size = expected_body_size + - (rstream->body_offset - rstream->hdr_offset); + rstream->mail_size = + next_body_offset - rstream->hdr_offset; i_stream_seek(stream, old_offset); return expected_body_size; }