summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--template.c15
2 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index f4862959..989a0c9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@ Version 7.2.2 [v7-stable] 2012-10-??
- bugfix: potential abort of imtcp on rsyslogd shutdown
- bugfix: imzmq3 segfault with PULL subscription
Thanks to Martin Nilsson for the patch.
+- bugfix: improper handling of backslash in string-type template()s
+- bugfix: leading quote (") in string-type template() lead to thight loop
+ on startup
----------------------------------------------------------------------------
Version 7.2.1 [v7-stable] 2012-10-29
- bugfix: ruleset()-object did only support a single statement
diff --git a/template.c b/template.c
index 2fc85e55..e8b95da3 100644
--- a/template.c
+++ b/template.c
@@ -547,9 +547,14 @@ tplConstruct(rsconf_t *conf)
/* helper to tplAddLine. Parses a constant and generates
* the necessary structure.
+ * Paramter "bDoEscapes" is to support legacy vs. v6+ config system. In
+ * legacy, we must do escapes ourselves, whereas v6+ passes in already
+ * escaped strings (which we are NOT permitted to further escape, this would
+ * cause invalid result strings!). Note: if escapes are not permitted,
+ * quotes (") are just a regular character and do NOT terminate the constant!
* returns: 0 - ok, 1 - failure
*/
-static int do_Constant(unsigned char **pp, struct template *pTpl)
+static int do_Constant(unsigned char **pp, struct template *pTpl, int bDoEscapes)
{
register unsigned char *p;
cstr_t *pStrB;
@@ -567,8 +572,8 @@ static int do_Constant(unsigned char **pp, struct template *pTpl)
/* process the message and expand escapes
* (additional escapes can be added here if needed)
*/
- while(*p && *p != '%' && *p != '\"') {
- if(*p == '\\') {
+ while(*p && *p != '%' && !(bDoEscapes && *p == '\"')) {
+ if(bDoEscapes && *p == '\\') {
switch(*++p) {
case '\0':
/* the best we can do - it's invalid anyhow... */
@@ -1233,7 +1238,7 @@ struct template *tplAddLine(rsconf_t *conf, char* pName, uchar** ppRestOfConfLin
do_Parameter(&p, pTpl);
break;
default: /* constant */
- do_Constant(&p, pTpl);
+ do_Constant(&p, pTpl, 1);
break;
}
if(*p == '"') {/* end of template string? */
@@ -1813,7 +1818,7 @@ tplProcessCnf(struct cnfobj *o)
do_Parameter(&p, pTpl);
break;
default: /* constant */
- do_Constant(&p, pTpl);
+ do_Constant(&p, pTpl, 0);
break;
}
}