[evolution-patches] 69776, multipart/signed failing




Patch makes the code handle data in a binary way rather than as c-strings.

--
Michael Zucchi <notzed ximian com>
"Evolution - Mostly Practiced By Dumb People"
Novell's Evolution and Free Software Developer
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2251.2.24
diff -u -p -r1.2251.2.24 ChangeLog
--- camel/ChangeLog	30 Nov 2004 07:56:07 -0000	1.2251.2.24
+++ camel/ChangeLog	1 Dec 2004 02:40:37 -0000
@@ -1,3 +1,13 @@
+2004-12-01  Not Zed  <NotZed Ximian com>
+
+	** See bug #69776.
+
+	* camel-multipart-signed.c (parse_boundary): take end of data
+	argument, so it handles binary data.  Use a binary data string
+	search rather than strstr.
+	(parse_content): dont bother to append a \0 on the end of the
+	data, not binary capable.
+
 2004-11-28	S.Ã?aÄ?lar Onur <caglar uludag org tr>
 
 	** See bug #69446.
Index: camel/camel-multipart-signed.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-multipart-signed.c,v
retrieving revision 1.22
diff -u -p -r1.22 camel-multipart-signed.c
--- camel/camel-multipart-signed.c	1 Dec 2003 01:30:45 -0000	1.22
+++ camel/camel-multipart-signed.c	1 Dec 2004 02:40:37 -0000
@@ -183,11 +183,16 @@ camel_multipart_signed_new (void)
 
 /* find the next boundary @bound from @start, return the start of the actual data
    @end points to the end of the data BEFORE the boundary */
-static char *parse_boundary(char *start, const char *bound, char **end)
+static char *parse_boundary(char *start, char *last, const char *bound, char **end)
 {
 	char *data, *begin;
 
-	begin = strstr(start, bound);
+	while ((begin = memchr(start, bound[0], last-start))) {
+		if (memcmp(begin, bound, strlen(bound)) == 0)
+			break;
+		start = begin+1;
+	}
+
 	if (begin == NULL)
 		return NULL;
 
@@ -232,14 +237,12 @@ parse_content(CamelMultipartSigned *mps)
 		return -1;
 	}
 
-	camel_stream_write((CamelStream *)mem, "", 1);
-	g_byte_array_set_size(mem->buffer, mem->buffer->len-1);
 	last = mem->buffer->data + mem->buffer->len;
 
 	bound = alloca(strlen(boundary)+5);
 	sprintf(bound, "--%s", boundary);
 
-	start = parse_boundary(mem->buffer->data, bound, &end);
+	start = parse_boundary(mem->buffer->data, last, bound, &end);
 	if (start == NULL || start[0] == 0)
 		return -1;
 
@@ -249,12 +252,12 @@ parse_content(CamelMultipartSigned *mps)
 		g_free(tmp);
 	}
 
-	start2 = parse_boundary(start, bound, &end);
+	start2 = parse_boundary(start, last, bound, &end);
 	if (start2 == NULL || start2[0] == 0)
 		return -1;
 
 	sprintf(bound, "--%s--", boundary);
-	post = parse_boundary(start2, bound, &end2);
+	post = parse_boundary(start2, last, bound, &end2);
 	if (post == NULL)
 		return -1;
 


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