[dovecot-cvs] dovecot/src/lib-mail message-parser.c,1.66,1.67

cras at dovecot.org cras at dovecot.org
Thu Jan 13 20:04:36 EET 2005


Update of /var/lib/cvs/dovecot/src/lib-mail
In directory talvi:/tmp/cvs-serv7670/lib-mail

Modified Files:
	message-parser.c 
Log Message:
MIME boundary parsing fix.



Index: message-parser.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-parser.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- message-parser.c	6 Jan 2005 22:26:40 -0000	1.66
+++ message-parser.c	13 Jan 2005 18:04:34 -0000	1.67
@@ -533,13 +533,23 @@
 	if (boundary == NULL)
 		return NULL;
 
-	/* now, see if it's end boundary */
-	end_boundary = FALSE;
-	if (i_stream_read_data(parser_ctx->input, &msg, &size,
-			       2 + boundary->len + 1) > 0) {
-		end_boundary = msg[boundary->len + 2] == '-' &&
-			msg[boundary->len + 2 + 1] == '-';
+	/* skip over to beginning of next line.
+	   size = "\r\n" + "--" + boundary + "--" */
+	(void)i_stream_read_data(parser_ctx->input, &msg, &size,
+				 2 + 2 + boundary->len + 2 - 1);
+	i_assert(size >= 3);
+	if (msg[0] == '\r') {
+		msg++; size--;
+	}
+	if (msg[0] == '\n') {
+		msg++; size--;
 	}
+	i_assert(size >= 2 && msg[0] == '-' && msg[1] == '-');
+	msg += 2; size -= 2;
+
+	/* now, see if it's end boundary. */
+	end_boundary = size >= boundary->len + 2 &&
+		msg[boundary->len] == '-' && msg[boundary->len + 1] == '-';
 
 	/* now, the boundary we found may not be what we expected.
 	   change boundary_size to be the found boundary's parent part */



More information about the dovecot-cvs mailing list