Xymon Mailing List Archive search

Alert Config Issues

list Henrik Størner
Mon, 23 May 2005 08:24:32 +0200
Message-Id: <user-3e7b5354a339@xymon.invalid>

On Mon, May 23, 2005 at 03:49:41PM +1200, Andy France wrote:
I'm starting to suspect it is to do with the order of the arguments, or
maybe whitespace issues.  Or, God forbid, oddball control characters which
have somehow ended up in the file.
Try this patch - it will complain loudly in the page.log file if it
finds high-ascii (> 0x7f) characters in the file, and then drop them
from the input.


Henrik


-------------- next part --------------
--- lib/misc.c	2005/05/20 20:54:08	1.32
+++ lib/misc.c	2005/05/23 06:19:20
@@ -209,14 +209,15 @@
 	return result;
 }
 
-void grok_input(char *l)
+void grok_input(unsigned char *l)
 {
 	/*
 	 * This routine sanitizes an input line, stripping off whitespace,
 	 * removing comments and un-escaping \-escapes and quotes.
 	 */
-	char *p, *outp;
+	unsigned char *p, *outp;
 	int inquote, inhyphen;
+	int didwarn = 0;
 
 	p = strchr(l, '\n'); if (p) *p = '\0';
 
@@ -238,6 +239,13 @@
 		else if ((*p == '#') && !inquote && !inhyphen) {
 			*p = '\0';
 		}
+		else if (*p > 0x7f) {
+			if (!didwarn) {
+				errprintf("Hi-ASCII character %02x dropped from input line '%s'\n", (int)*p, l);
+				didwarn = 1;
+			}
+			p++;
+		}
 		else {
 			if (outp != p) *outp = *p;
 			outp++; p++;
--- lib/misc.h	2005/05/20 20:54:08	1.18
+++ lib/misc.h	2005/05/23 06:06:27
@@ -24,7 +24,7 @@
 extern void addtobuffer(char **buf, int *bufsz, char *newtext);
 extern char *msg_data(char *msg);
 extern char *gettok(char *s, char *delims);
-extern void grok_input(char *s);
+extern void grok_input(unsigned char *s);
 extern unsigned int IPtou32(int ip1, int ip2, int ip3, int ip4);
 extern char *u32toIP(unsigned int ip32);
 extern const char *textornull(const char *text);