dovecot-1.2: mbox: If Content-Length: is correct, don't break if...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Oct 29 20:01:42 EET 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/9873654f9c48
changeset: 8353:9873654f9c48
user: Timo Sirainen <tss at iki.fi>
date: Wed Oct 29 20:01:39 2008 +0200
description:
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.
diffstat:
1 file changed, 15 insertions(+), 5 deletions(-)
src/lib-storage/index/mbox/istream-raw-mbox.c | 20 +++++++++++++++-----
diffs (38 lines):
diff -r 1dc1f8163166 -r 9873654f9c48 src/lib-storage/index/mbox/istream-raw-mbox.c
--- 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 @@ uoff_t istream_raw_mbox_get_body_size(st
(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 @@ uoff_t istream_raw_mbox_get_body_size(st
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;
}
More information about the dovecot-cvs
mailing list