dovecot-1.2: message-header-parsed: Backported fixes from v2.0.

dovecot at dovecot.org dovecot at dovecot.org
Tue Dec 22 21:20:04 EET 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/a1622da31bb1
changeset: 9516:a1622da31bb1
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Dec 22 14:02:10 2009 -0500
description:
message-header-parsed: Backported fixes from v2.0.

diffstat:

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

diffs (66 lines):

diff -r b934756a3714 -r a1622da31bb1 src/lib-mail/message-header-parser.c
--- a/src/lib-mail/message-header-parser.c	Thu Dec 17 14:00:30 2009 -0500
+++ b/src/lib-mail/message-header-parser.c	Tue Dec 22 14:02:10 2009 -0500
@@ -107,7 +107,7 @@ int message_parse_header_next(struct mes
 				return -1;
 			}
 
-			if (size > 0 &&
+			if (size > 0 && !ctx->skip_line &&
 			    (msg[0] == '\n' ||
 			     (msg[0] == '\r' && size > 1 && msg[1] == '\n'))) {
 				/* end of headers - this mostly happens just
@@ -136,6 +136,7 @@ int message_parse_header_next(struct mes
 			   b) header ended unexpectedly */
 			if (colon_pos == UINT_MAX && ret == -2 && !continued) {
 				/* header name is huge. just skip it. */
+				i_assert(size > 1);
 				if (msg[size-1] == '\r')
 					size--;
 
@@ -172,7 +173,7 @@ int message_parse_header_next(struct mes
 				if (msg[i] > ':')
 					continue;
 
-				if (msg[i] == ':') {
+				if (msg[i] == ':' && !ctx->skip_line) {
 					colon_pos = i;
 					line->full_value_offset =
 						ctx->input->v_offset + i + 1;
@@ -203,20 +204,19 @@ int message_parse_header_next(struct mes
 		if (i < parse_size) {
 			/* got a line */
 			if (ctx->skip_line) {
-				/* skipping a huge line */
+				/* skipping a line with a huge header name */
 				if (ctx->hdr_size != NULL) {
-					ctx->hdr_size->physical_size += i;
-					ctx->hdr_size->virtual_size += i;
-				}
-
+					ctx->hdr_size->lines++;
+					ctx->hdr_size->physical_size += i + 1;
+					ctx->hdr_size->virtual_size += i + 1;
+				}
 				if (i == 0 || msg[i-1] != '\r') {
 					/* missing CR */
 					if (ctx->hdr_size != NULL)
 						ctx->hdr_size->virtual_size++;
-				} else {
-					crlf_newline = TRUE;
-				}
-				i_stream_skip(ctx->input, i);
+				}
+
+				i_stream_skip(ctx->input, i + 1);
 				startpos = 0;
 				ctx->skip_line = FALSE;
 				continue;
@@ -355,7 +355,6 @@ int message_parse_header_next(struct mes
 		}
 		line->full_value = buffer_get_data(ctx->value_buf,
 						   &line->full_value_len);
-		line->value = line->full_value + value_pos;
 	} else {
 		/* we didn't want full_value, and this is a continued line. */
 		line->full_value = NULL;


More information about the dovecot-cvs mailing list