summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-11-29 11:21:09 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-11-29 11:21:09 +0100
commit5e863f50de52780aebfc808ef44635900ab27909 (patch)
treef9f7a02fbbd048a52fac84eb033af25bd7b22b52
parent60217da3968bcc62048f6afd4c8c77565789c3da (diff)
downloadrsyslog-5e863f50de52780aebfc808ef44635900ab27909.tar.gz
rsyslog-5e863f50de52780aebfc808ef44635900ab27909.tar.bz2
rsyslog-5e863f50de52780aebfc808ef44635900ab27909.zip
bugfix: no error message for invalid string template parameters
rather a malformed template was generated, and error information emitted at runtime. However, this could be quite confusing. Note that with this "bugfix" user experience changes: formerly, rsyslog and the affected actions properly started up, but the actions did not produce proper data. Now, there are startup error messages and the actions are NOT executed (due to missing template due to template error).
-rw-r--r--ChangeLog7
-rw-r--r--doc/v7compatibility.html10
-rw-r--r--runtime/rsyslog.h1
-rw-r--r--template.c14
4 files changed, 28 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ebf16c6d..5926f208 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
Version 7.3.5 [devel] 2012-11-??
- bugfix: mmnormalize build problems
- bugfix: mmnormalize could abort rsyslog if config parameter was in error
+- bugfix: no error message for invalid string template parameters
+ rather a malformed template was generated, and error information emitted
+ at runtime. However, this could be quite confusing. Note that with this
+ "bugfix" user experience changes: formerly, rsyslog and the affected
+ actions properly started up, but the actions did not produce proper
+ data. Now, there are startup error messages and the actions are NOT
+ executed (due to missing template due to template error).
---------------------------------------------------------------------------
Version 7.3.4 [devel] 2012-11-23
- further (and rather drastically) improved disk queue performance
diff --git a/doc/v7compatibility.html b/doc/v7compatibility.html
index 24c17d72..51f99118 100644
--- a/doc/v7compatibility.html
+++ b/doc/v7compatibility.html
@@ -89,6 +89,16 @@ environments it is highly recommended NOT to use "last message repeated n times"
processing but rather the other (more efficient) rate-limiting methods. These
also do NOT require the parsing step to be done during input processing.
+<h2>Stricter string-template Processing</h2>
+<p>Previously, no error message for invalid string template parameters
+was generated.
+Rather a malformed template was generated, and error information emitted
+at runtime. However, this could be quite confusing. Note that the new code
+changes user experience: formerly, rsyslog and the affected
+actions properly started up, but the actions did not produce proper
+data. Now, there are startup error messages and the actions are NOT
+executed (due to missing template due to template error).
+
<p><font size="2">This documentation is part of the
<a href="http://www.rsyslog.com/">rsyslog</a> project.<br>
Copyright &copy; 2011-2012 by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a> and
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index a826decb..c00b5d95 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -396,6 +396,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_RULESET_EXISTS = -2306,/**< ruleset already exists */
RS_RET_DEPRECATED = -2307,/**< deprecated functionality is used */
RS_RET_DS_PROP_SEQ_ERR = -2308,/**< property sequence error deserializing object */
+ RS_RET_TPL_INVLD_PROP = -2309,/**< property name error in template (unknown name) */
/* RainerScript error messages (range 1000.. 1999) */
RS_RET_SYSVAR_NOT_FOUND = 1001, /**< system variable could not be found (maybe misspelled) */
diff --git a/template.c b/template.c
index 67a58b03..06a0c39a 100644
--- a/template.c
+++ b/template.c
@@ -799,7 +799,6 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
assert(pp != NULL);
assert(*pp != NULL);
assert(pTpl != NULL);
-
p = (unsigned char*) *pp;
if(cstrConstruct(&pStrProp) != RS_RET_OK)
@@ -821,6 +820,8 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
cstrFinalize(pStrProp);
if(propNameToID(pStrProp, &pTpe->data.field.propid) != RS_RET_OK) {
+ errmsg.LogError(0, RS_RET_TPL_INVLD_PROP, "template '%s': invalid parameter '%s'",
+ pTpl->pszName, cstrGetSzStrNoNULL(pStrProp));
cstrDestruct(&pStrProp);
return 1;
}
@@ -1211,7 +1212,6 @@ struct template *tplAddLine(rsconf_t *conf, char* pName, uchar** ppRestOfConfLin
assert(pName != NULL);
assert(ppRestOfConfLine != NULL);
-
if((pTpl = tplConstruct(conf)) == NULL)
return NULL;
@@ -1274,7 +1274,10 @@ struct template *tplAddLine(rsconf_t *conf, char* pName, uchar** ppRestOfConfLin
break;
case '%': /* parameter */
++p; /* eat '%' */
- do_Parameter(&p, pTpl);
+ if(do_Parameter(&p, pTpl) != 0) {
+ dbgprintf("tplAddLine error: parameter invalid");
+ return NULL;
+ };
break;
default: /* constant */
do_Constant(&p, pTpl, 1);
@@ -1871,7 +1874,10 @@ tplProcessCnf(struct cnfobj *o)
switch(*p) {
case '%': /* parameter */
++p; /* eat '%' */
- do_Parameter(&p, pTpl);
+ if(do_Parameter(&p, pTpl) != 0) {
+ dbgprintf("tplProcessConf error: parameter invalid");
+ ABORT_FINALIZE(RS_RET_ERR);
+ };
break;
default: /* constant */
do_Constant(&p, pTpl, 0);