summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-05-27 11:01:29 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2013-05-27 11:01:29 +0200
commit6ded646baf52a9dfd8f0d819d1e7705e58c45e80 (patch)
tree97e2d6dbbadb1b5cacae8954a6556ed4ea4b34a4
parent5605b1b60ae6bd8939c083cc043c4d7ec01cef8c (diff)
downloadrsyslog-6ded646baf52a9dfd8f0d819d1e7705e58c45e80.tar.gz
rsyslog-6ded646baf52a9dfd8f0d819d1e7705e58c45e80.tar.bz2
rsyslog-6ded646baf52a9dfd8f0d819d1e7705e58c45e80.zip
bugfix: $template statement with multiple spaces lead to invalid tpl name
If multiple spaces were used in front of the template name, all but one of them became actually part of the template name. So $template a,"..." would be name " a", and as such "a" was not available, e.g. in *.* /var/log/file;a This is a legacy config problem. As it was unreported for many years, no backport of the fix to old versions will happen. This is a long-standing bug that was only recently reported by forum user mc-sim. Reference: http://kb.monitorware.com/post23448.html
-rw-r--r--ChangeLog11
-rw-r--r--runtime/conf.c18
-rw-r--r--template.c1
3 files changed, 30 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 3b39b369..fc70b515 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,17 @@ Version 7.3.16 [beta] 2013-05-??
- bugfix: potential hang *in debug mode* on rsyslogd termination
This ONLY affected rsyslogd if it were running with debug output
enabled.
+- bugfix: $template statement with multiple spaces lead to invalid tpl name
+ If multiple spaces were used in front of the template name, all but one
+ of them became actually part of the template name. So
+ $template a,"..." would be name " a", and as such "a" was not
+ available, e.g. in
+ *.* /var/log/file;a
+ This is a legacy config problem. As it was unreported for many years,
+ no backport of the fix to old versions will happen.
+ This is a long-standing bug that was only recently reported by forum
+ user mc-sim.
+ Reference: http://kb.monitorware.com/post23448.html
---------------------------------------------------------------------------
Version 7.3.15 [beta] 2013-05-15
- bugfix: problem in build system (especially when cross-compiling)
diff --git a/runtime/conf.c b/runtime/conf.c
index c97391c6..c3c7e447 100644
--- a/runtime/conf.c
+++ b/runtime/conf.c
@@ -129,6 +129,23 @@ finalize_it:
}
+/* remove leading spaces from name; this "fixes" some anomalies in
+ * getSubString(), but I was not brave enough to fix the former as
+ * it has many other callers... -- rgerhards, 2013-05-27
+ */
+static inline void
+ltrim(char *src)
+{
+ char *dst = src;
+ while(isspace(*src))
+ ++src; /*SKIP*/;
+ if(dst != src) {
+ while(*src != '\0')
+ *dst++ = *src++;
+ *dst = '\0';
+ }
+}
+
/* parse and interpret a $-config line that starts with
* a name (this is common code). It is parsed to the name
* and then the proper sub-function is called to handle
@@ -155,6 +172,7 @@ doNameLine(uchar **pp, void* pVal)
errmsg.LogError(0, RS_RET_NOT_FOUND, "Invalid config line: could not extract name - line ignored");
ABORT_FINALIZE(RS_RET_NOT_FOUND);
}
+ ltrim(szName);
if(*p == ',')
++p; /* comma was eaten */
diff --git a/template.c b/template.c
index c48bf4bd..b6752551 100644
--- a/template.c
+++ b/template.c
@@ -1184,6 +1184,7 @@ struct template *tplAddLine(rsconf_t *conf, char* pName, uchar** ppRestOfConfLin
if((pTpl = tplConstruct(conf)) == NULL)
return NULL;
+ DBGPRINTF("tplAddLine processing template '%s'\n", pName);
pTpl->iLenName = strlen(pName);
pTpl->pszName = (char*) MALLOC(sizeof(char) * (pTpl->iLenName + 1));
if(pTpl->pszName == NULL) {