changeset 1413:f9f69a6fdd63 HEAD

We stopped parsing message if there was a line longer than input buffer (8192 bytes).
author Timo Sirainen <tss@iki.fi>
date Sat, 03 May 2003 20:28:20 +0300
parents ac714d7d0b67
children dcc9b7b868d8
files src/lib-mail/message-parser.c
diffstat 1 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-mail/message-parser.c	Sat May 03 19:31:12 2003 +0300
+++ b/src/lib-mail/message-parser.c	Sat May 03 20:28:20 2003 +0300
@@ -350,7 +350,8 @@
 			if (msg[i] != '\n')
 				continue;
 
-			if (i >= line_start+2 && msg[line_start] == '-' &&
+			if (line_start != (size_t)-1 &&
+			    i >= line_start+2 && msg[line_start] == '-' &&
 			    msg[line_start+1] == '-') {
 				/* possible boundary */
 				boundary = boundary_find(boundaries,
@@ -372,21 +373,26 @@
 		if (boundary != NULL)
 			break;
 
-		if (i - line_start > 128 &&
-		    msg[line_start] == '-' && msg[line_start+1] == '-') {
+		if (line_start == (size_t)-1) {
+			/* continued long line, continue skipping over it */
+		} else if (i - line_start > 128) {
 			/* long partial line, see if it's a boundary.
 			   RFC-2046 says that the boundaries must be
 			   70 chars without "--" or less. We allow
 			   a bit larger.. */
-			boundary = boundary_find(boundaries,
-						 msg + line_start + 2,
-						 i - line_start - 2);
-			if (boundary != NULL)
-				break;
+			if (msg[line_start] == '-' &&
+			    msg[line_start+1] == '-') {
+				boundary = boundary_find(boundaries,
+							 msg + line_start + 2,
+							 i - line_start - 2);
+				if (boundary != NULL)
+					break;
+			}
 
 			/* nope, we can skip over the line, just
 			   leave the last char since it may be \r */
 			i--;
+			line_start = (size_t)-1;
 		} else {
 			/* leave the last line to buffer, it may be
 			   boundary */
@@ -403,7 +409,8 @@
 		startpos = size - i;
 	}
 
-	if (boundary == NULL && line_start+2 <= size &&
+	if (boundary == NULL &&
+	    line_start != (size_t)-1 && line_start+2 <= size &&
 	    msg[line_start] == '-' && msg[line_start+1] == '-') {
 		/* possible boundary without line feed at end */
 		boundary = boundary_find(boundaries,
@@ -412,6 +419,7 @@
 	}
 
 	if (boundary != NULL) {
+		i_assert(line_start != (size_t)-1);
 		if (skip_over) {
 			/* leave the pointer right after the boundary */
 			line_start += 2 + boundary->len;