dovecot-2.0: istream-header-filter: Fixes handling HEADER_FILTER...

dovecot at dovecot.org dovecot at dovecot.org
Thu Feb 10 02:51:24 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/079a81fb5117
changeset: 12593:079a81fb5117
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Feb 10 02:51:22 2011 +0200
description:
istream-header-filter: Fixes handling HEADER_FILTER_END_BODY_WITH_LF correctly.

diffstat:

 src/lib-mail/istream-header-filter.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r 4374ae187075 -r 079a81fb5117 src/lib-mail/istream-header-filter.c
--- a/src/lib-mail/istream-header-filter.c	Thu Feb 10 02:21:03 2011 +0200
+++ b/src/lib-mail/istream-header-filter.c	Thu Feb 10 02:51:22 2011 +0200
@@ -318,7 +318,9 @@
 
 	if (ret == -1 && stream->parent->eof && !last_lf) {
 		/* missing LF, need to add it */
+		i_assert(!mstream->last_lf_added);
 		i_assert(size == 0 || data[size-1] != '\n');
+
 		buffer_reset(mstream->hdr_buf);
 		buffer_append(mstream->hdr_buf, data, size);
 		if (mstream->crlf)
@@ -328,7 +330,7 @@
 		mstream->last_lf_added = TRUE;
 
 		stream->skip = 0;
-		stream->pos = size + 1;
+		stream->pos = mstream->hdr_buf->used;
 		stream->buffer = mstream->hdr_buf->data;
 		return mstream->crlf ? 2 : 1;
 	} else {
@@ -425,8 +427,6 @@
 	struct header_filter_istream *mstream =
 		(struct header_filter_istream *)stream;
 
-	mstream->last_lf_added = FALSE;
-
 	if (stream->istream.v_offset == v_offset) {
 		/* just reset the input buffer */
 		stream_reset_to(mstream, v_offset);
@@ -434,6 +434,9 @@
 			      mstream->istream.parent_expected_offset);
 		return;
 	}
+	/* if last_lf_added=TRUE, we're currently at EOF. So reset it only if
+	   we're seeking backwards, otherwise we would just add a duplicate */
+	mstream->last_lf_added = FALSE;
 
 	if (v_offset == 0) {
 		/* seeking to beginning of headers. */


More information about the dovecot-cvs mailing list