summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-04 09:52:39 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-04 09:52:39 +0000
commitea0d1c36e24db522dc805edf0b42ffe4372dbff8 (patch)
tree9520bcfb35a0b6ca0eb7848c5a939b0cb35156ef
parent456c701f8cc82b30babb0234dc6bac827859b21a (diff)
downloadrsyslog-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.c18
1 files changed, 16 insertions, 2 deletions
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);
+ }
}