[PATCH] Bug#317524: infinite loop when using charset_default=iso-8859-1

David Relson <[email protected]> Fri, 4 Nov 2005 19:26:33 -0500
Newsgroups gmane.mail.bogofilter.devel
Organization Osage Software Systems, Inc.
Message-ID <[email protected]>
Renamed the attachment so that mailman won't delete it.

_______________________________________________
Bogofilter-dev mailing list
[email protected]
http://www.bogofilter.org/mailman/listinfo/bogofilter-dev
patch.1104.charset.name.error.txt (text/plain, 1.7 KB)
diff -u -r1.232 bogoconfig.c
--- bogoconfig.c	15 Oct 2005 20:52:51 -0000	1.232
+++ bogoconfig.c	5 Nov 2005 00:14:39 -0000
@@ -169,6 +169,23 @@
 static char *get_string(const char *name, const char *arg)
 {
     char *s = xstrdup(arg);
+
+    /* scan option to delete comment (after '#') and preceding whitespace */
+    char *t = s;
+    bool quote = false;
+    for (t = s; *t != '\0' ; t += 1)
+    {
+	char c = *t;
+	if (c == '"')
+	    quote ^= true;
+	if (!quote && c == '#') {
+	    *t-- = '\0';
+	    while (isspace(*t))
+		*t-- = '\0';
+	    break;
+	}
+    }
+
     if (DEBUG_CONFIG(2))
 	fprintf(dbgout, "%s -> '%s'\n", name, s);
     return s;
diff -u -r1.90 bogolexer.c
--- bogolexer.c	17 Jun 2005 03:31:06 -0000	1.90
+++ bogolexer.c	5 Nov 2005 00:14:39 -0000
@@ -92,6 +92,23 @@
 static char *get_string(const char *name, const char *arg)
 {
     char *s = xstrdup(arg);
+
+    /* scan option to delete comment (after '#') and preceding whitespace */
+    char *t = s;
+    bool quote = false;
+    for (t = s; *t != '\0' ; t += 1)
+    {
+	char c = *t;
+	if (c == '"')
+	    quote ^= true;
+	if (!quote && c == '#') {
+	    *t-- = '\0';
+	    while (isspace(*t))
+		*t-- = '\0';
+	    break;
+	}
+    }
+
     if (DEBUG_CONFIG(2))
 	fprintf(dbgout, "%s -> '%s'\n", name, s);
     return s;
diff -u -r1.13 convert_unicode.c
--- convert_unicode.c	26 Jun 2005 01:06:26 -0000	1.13
+++ convert_unicode.c	5 Nov 2005 00:14:39 -0000
@@ -33,7 +33,7 @@
 #define	SP	' '
 
 #include <iconv.h>
-iconv_t cd;
+iconv_t cd = NULL;
 
 static void map_nonascii_characters(void)
 {
@@ -135,6 +135,8 @@
 	from_charset = charset_default;
 
     cd = bf_iconv_open( to_charset, from_charset );
+    if (cd == (iconv_t) -1)
+	cd = NULL;
 
     for (idx = 0; idx < COUNTOF(charsets); idx += 1)
     {