dovecot-1.2: message header parser: Don't set hdr->continues=TRU...

dovecot at dovecot.org dovecot at dovecot.org
Tue May 26 23:53:47 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/eead0542095f
changeset: 9096:eead0542095f
user:      Timo Sirainen <tss at iki.fi>
date:      Tue May 26 16:53:29 2009 -0400
description:
message header parser: Don't set hdr->continues=TRUE when hdr->eoh=TRUE.
This happened if body began with LWSP. Also if parser has seen eoh but not
the following character, don't bother waiting for it.

diffstat:

1 file changed, 11 insertions(+), 8 deletions(-)
src/lib-mail/message-header-parser.c |   19 +++++++++++--------

diffs (43 lines):

diff -r 9a0aa39a3a14 -r eead0542095f src/lib-mail/message-header-parser.c
--- a/src/lib-mail/message-header-parser.c	Tue May 26 14:21:59 2009 -0400
+++ b/src/lib-mail/message-header-parser.c	Tue May 26 16:53:29 2009 -0400
@@ -106,14 +106,10 @@ int message_parse_header_next(struct mes
 				/* error / EOF with no bytes */
 				return -1;
 			}
-			if (ret == 0 && !ctx->input->eof) {
-				/* stream is nonblocking - need more data */
-				return 0;
-			}
-			i_assert(size > 0);
-
-			if (msg[0] == '\n' ||
-			    (msg[0] == '\r' && size > 1 && msg[1] == '\n')) {
+
+			if (size > 0 &&
+			    (msg[0] == '\n' ||
+			     (msg[0] == '\r' && size > 1 && msg[1] == '\n'))) {
 				/* end of headers - this mostly happens just
 				   with mbox where headers are read separately
 				   from body */
@@ -130,6 +126,11 @@ int message_parse_header_next(struct mes
 				}
 				break;
 			}
+			if (ret == 0 && !ctx->input->eof) {
+				/* stream is nonblocking - need more data */
+				return 0;
+			}
+			i_assert(size > 0);
 
 			/* a) line is larger than input buffer
 			   b) header ended unexpectedly */
@@ -256,6 +257,8 @@ int message_parse_header_next(struct mes
 		line->name_len = line->value_len = line->full_value_len = 0;
 		line->name = ""; line->value = line->full_value = NULL;
 		line->middle = NULL; line->middle_len = 0;
+		line->full_value_offset = line->name_offset;
+		line->continues = FALSE;
 	} else if (line->continued) {
 		line->value = msg;
 		line->value_len = size;


More information about the dovecot-cvs mailing list