[PATCH] non-compliant encoded text causes 0.15.3 segfault

David Relson relson at osagesoftware.com
Thu Sep 11 13:59:18 CEST 2003


pi,

Here's a patch that fixes the segfault caused by the non-compliant
encoded text.  This should get you going.

David


Index: lexer.c
===================================================================
RCS file: /cvsroot/bogofilter/bogofilter/src/lexer.c,v
retrieving revision 1.71
diff -u -r1.71 lexer.c
--- lexer.c	8 Sep 2003 13:10:30 -0000	1.71
+++ lexer.c	11 Sep 2003 11:55:48 -0000
@@ -266,9 +266,19 @@
 
     while (txt < fin) {
 	word_t n;
-	char *typ = strchr(txt+2, '?') + 1;	/* Encoding type - 'B' or 'Q' */
-	char *end = strstr(typ+2, "?=");	/* last char of encoded word  */
-	size_t len = end - (typ+2);
+	char *typ;			/* Encoding type - 'B' or 'Q' */
+	char *end;			/* last char of encoded word  */
+	size_t len;
+
+	if (txt == NULL)
+	    break;
+	typ = strchr(txt+2, '?');
+	if (typ == NULL)
+	    break;
+	end = strstr(typ+2, "?=");
+	if (end == NULL)
+	    break;
+	len = end - (typ+2);
 
 	n.text = (byte *)(typ + 2);		/* Start of encoded word */
 	n.leng = len;				/* Length of encoded word */




More information about the Bogofilter mailing list