[gmime-devel] [Patch] Fix two issues in gmime 2.4.1 (and current SVN) - segfault fix



Here are two messages that will crash gmime 2.4.1 and current SVN.

First is a message with a header that contains only white space chars.
Second is a short message which crashes gmime probably because it has
UNIX style EOL chars and gmime assumes that lines contain at least 2
chars.

Both bugs are patched.

-- 
Damian Pietras
--- Begin Message ---
This is a multi-part message in MIME format.



--- End Message ---
--- Begin Message ---

--- End Message ---
Index: gmime/gmime-parser.c
===================================================================
--- gmime/gmime-parser.c	(revision 1492)
+++ gmime/gmime-parser.c	(working copy)
@@ -1213,7 +1213,7 @@
 {
 	gint64 offset = parser_offset (priv, start);
 	
-	if (start[len - 1] == '\r')
+	if (len > 0 && start[len - 1] == '\r')
 		len--;
 	
 	if (possible_boundary (priv->scan_from, start, len)) {
diff -urp gmime-2.4.1/gmime/gmime-parser.c gmime-2.4.1-fix/gmime/gmime-parser.c
--- gmime-2.4.1/gmime/gmime-parser.c	2008-10-02 05:08:48.000000000 +0200
+++ gmime-2.4.1-fix/gmime/gmime-parser.c	2008-10-06 14:42:21.000000000 +0200
@@ -863,7 +863,7 @@ header_parse (GMimeParser *parser, struc
 		inptr++;
 	
 	/* cut trailing lwsp */
-	start = inptr++;
+	start = inptr;
 	end = inptr;
 	
 	while (*inptr) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]