summaryrefslogtreecommitdiffstats
path: root/runtime/conf.c
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 /runtime/conf.c
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
Diffstat (limited to 'runtime/conf.c')
-rw-r--r--runtime/conf.c18
1 files changed, 18 insertions, 0 deletions
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 */