summaryrefslogtreecommitdiffstats
path: root/template.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-11-08 17:41:10 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-11-08 17:41:10 +0100
commit00edf1573fc240a78e2516b0945ce41167c5977d (patch)
treee047f209d7b9bd85a44ca0414fc8056852df3e73 /template.c
parent33713481095660a3bc2e220961c21f385c2d1765 (diff)
downloadrsyslog-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
Diffstat (limited to 'template.c')
-rw-r--r--template.c15
1 files changed, 10 insertions, 5 deletions
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;
}
}