From ea0d1c36e24db522dc805edf0b42ffe4372dbff8 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 4 Jul 2007 09:52:39 +0000 Subject: checks for extra (unexpected) characters in system config file lines have been added --- syslogd.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'syslogd.c') diff --git a/syslogd.c b/syslogd.c index 5f412890..5fb712aa 100644 --- a/syslogd.c +++ b/syslogd.c @@ -2,8 +2,6 @@ * \brief This is the main file of the rsyslogd daemon. * * TODO: - * - check template lines for extra characters and provide - * a warning, if they exists * - include a global option for control character replacemet on receive? (not just NUL) * * Please note that as of now, a lot of the code in this file stems @@ -6960,6 +6958,7 @@ static void doNameLine(unsigned char **pp, enum eDirective eDir) void cfsysline(unsigned char *p) { unsigned char szCmd[32]; + unsigned char errMsg[128]; /* for dynamic error messages */ assert(p != NULL); errno = 0; @@ -6987,6 +6986,21 @@ void cfsysline(unsigned char *p) logerror(err); return; } + + /* now check if we have some extra characters left on the line - that + * should not be the case. Whitespace is OK, but everything else should + * trigger a warning (that may be an indication of undesired behaviour. + * rgerhards, 2007-07-04 + */ + while(*p && isspace(*p)) + ++p; /* skip it */ + + if(*p) { /* we have a non-whitespace, so let's complain */ + snprintf((char*) errMsg, sizeof(errMsg)/sizeof(unsigned char), + "error: extra characters in config line ignored: '%s'", p); + errno = 0; + logerror((char*) errMsg); + } } -- cgit v1.2.3