dovecot-1.2: mbox: Fix to handling CRs before From_ lines.

dovecot at dovecot.org dovecot at dovecot.org
Fri May 1 20:15:35 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/d2d93c02dc7b
changeset: 9004:d2d93c02dc7b
user:      Timo Sirainen <tss at iki.fi>
date:      Fri May 01 13:15:30 2009 -0400
description:
mbox: Fix to handling CRs before From_ lines.

diffstat:

1 file changed, 11 insertions(+), 11 deletions(-)
src/lib-storage/index/mbox/istream-raw-mbox.c |   22 +++++++++++-----------

diffs (42 lines):

diff -r 2f895db2af46 -r d2d93c02dc7b src/lib-storage/index/mbox/istream-raw-mbox.c
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c	Fri May 01 13:05:45 2009 -0400
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.c	Fri May 01 13:15:30 2009 -0400
@@ -295,19 +295,19 @@ static ssize_t i_stream_raw_mbox_read(st
 				/* potential From-line, see if we have the
 				   rest of the line buffered. */
 				i++;
+				if (i >= 7 && buf[i-7] == '\r') {
+					/* CR also belongs to it. */
+					crlf_ending = TRUE;
+					from_start_pos = i - 7;
+				} else {
+					crlf_ending = FALSE;
+					from_start_pos = i - 6;
+				}
+
 				if (rstream->hdr_offset + rstream->mail_size ==
-				    stream->istream.v_offset + i - 6 ||
+				    stream->istream.v_offset + from_start_pos ||
 				    rstream->mail_size == (uoff_t)-1) {
 					from_after_pos = i;
-					from_start_pos = i - 6;
-					if (from_start_pos > 0 &&
-					    buf[from_start_pos-1] == '\r') {
-						/* CR also belongs to it. */
-						crlf_ending = TRUE;
-						from_start_pos--;
-					} else {
-						crlf_ending = FALSE;
-					}
 					if (ret == -2) {
 						/* even if we don't have the
 						   whole line, we need to
@@ -316,7 +316,7 @@ static ssize_t i_stream_raw_mbox_read(st
 					}
 				}
 				fromp = mbox_from;
-			} else if (from_start_pos != (size_t)-1) {
+			} else if (from_after_pos != (size_t)-1) {
 				/* we have the whole From-line here now.
 				   See if it's a valid one. */
 			mbox_verify:


More information about the dovecot-cvs mailing list