diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-11-08 17:41:10 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-11-08 17:41:10 +0100 |
commit | 00edf1573fc240a78e2516b0945ce41167c5977d (patch) | |
tree | e047f209d7b9bd85a44ca0414fc8056852df3e73 | |
parent | 33713481095660a3bc2e220961c21f385c2d1765 (diff) | |
download | rsyslog-00edf1573fc240a78e2516b0945ce41167c5977d.tar.gz rsyslog-00edf1573fc240a78e2516b0945ce41167c5977d.tar.bz2 rsyslog-00edf1573fc240a78e2516b0945ce41167c5977d.zip |
bugfixes in string-type template()S
Both are closely related and thus rolled into a single commit.
- bugfix: improper handling of backslash in string-type template()s
- bugfix: leading quote (") in string-type template() lead to thight loop
on startup
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | template.c | 15 |
2 files changed, 13 insertions, 5 deletions
@@ -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 @@ -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; } } |