diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-04 09:52:39 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-04 09:52:39 +0000 |
commit | ea0d1c36e24db522dc805edf0b42ffe4372dbff8 (patch) | |
tree | 9520bcfb35a0b6ca0eb7848c5a939b0cb35156ef | |
parent | 456c701f8cc82b30babb0234dc6bac827859b21a (diff) | |
download | rsyslog-ea0d1c36e24db522dc805edf0b42ffe4372dbff8.tar.gz rsyslog-ea0d1c36e24db522dc805edf0b42ffe4372dbff8.tar.xz rsyslog-ea0d1c36e24db522dc805edf0b42ffe4372dbff8.zip |
checks for extra (unexpected) characters in system config file lines have
been added
-rw-r--r-- | syslogd.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -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); + } } |