From de652e16a83e8e53f63b81caa0bcc0d7fbc04263 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 19 Nov 2013 10:39:21 +0100 Subject: bugfix: segfault on startup when certain script constructs are used e.g. "if not $msg ..." --- ChangeLog | 2 ++ grammar/rainerscript.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 035b8fc1..dd353683 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ --------------------------------------------------------------------------- Version 7.4.7 [v7.4-stable] 2013-11-?? +- bugfix: segfault on startup when certain script constructs are used + e.g. "if not $msg ..." - bugfix: imuxsock: UseSysTimeStamp config parameter did not work correctly Thanks to Tomas Heinrich for alerting us and provinding a solution suggestion. diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index a1de6442..25d9c9a4 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -2737,6 +2737,9 @@ cnfexprOptimize_CMP_severity_facility(struct cnfexpr *expr) { struct cnffunc *func; + if(expr->l->nodetype != 'V') + FINALIZE; + if(!strcmp("$syslogseverity", ((struct cnfvar*)expr->l)->name)) { if(expr->r->nodetype == 'N') { int sev = (int) ((struct cnfnumval*)expr->r)->val; @@ -2766,6 +2769,7 @@ cnfexprOptimize_CMP_severity_facility(struct cnfexpr *expr) } } } +finalize_it: return expr; } -- cgit v1.2.3 From 4aa409ffe508509a10f8a69a674d49349d365c42 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 19 Nov 2013 11:42:31 +0100 Subject: testbench: add new test --- tests/Makefile.am | 1 + tests/stop-localvar.sh | 12 ++++++++++++ tests/testsuites/stop-localvar.conf | 21 +++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100755 tests/stop-localvar.sh create mode 100644 tests/testsuites/stop-localvar.conf diff --git a/tests/Makefile.am b/tests/Makefile.am index b339e797..d95b0766 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,6 +6,7 @@ TESTS = $(TESTRUNS) if ENABLE_IMDIAG TESTS += \ + stop-localvar.sh \ arrayqueue.sh \ da-mainmsg-q.sh \ validation-run.sh \ diff --git a/tests/stop-localvar.sh b/tests/stop-localvar.sh new file mode 100755 index 00000000..91573013 --- /dev/null +++ b/tests/stop-localvar.sh @@ -0,0 +1,12 @@ +# Test for "stop" statement +# This file is part of the rsyslog project, released under ASL 2.0 +echo =============================================================================== +echo \[stop-localvar.sh\]: testing stop statement together with local variables +source $srcdir/diag.sh init +source $srcdir/diag.sh startup stop-localvar.conf +sleep 1 +source $srcdir/diag.sh tcpflood -m2000 -i1 +source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages +source $srcdir/diag.sh wait-shutdown +source $srcdir/diag.sh seq-check 100 999 +source $srcdir/diag.sh exit diff --git a/tests/testsuites/stop-localvar.conf b/tests/testsuites/stop-localvar.conf new file mode 100644 index 00000000..020ebd87 --- /dev/null +++ b/tests/testsuites/stop-localvar.conf @@ -0,0 +1,21 @@ +/* note: variables are strings (at least in v7), so we need to convert + * to a number when we check the conditon. + * Even if we change the variable representation at some later point, + * we should NOT change this test here, but better add a new one. + * rgerhards, 2013-11-19 + */ +$IncludeConfig diag-common.conf +template(name="outfmt" type="string" string="%$!nbr%\n") + +module(load="../plugins/imtcp/.libs/imtcp") +input(type="imtcp" port="13514") + +if $msg contains "msgnum:" then { + set $!nbr = field($msg, 58, 2); + if cnum($!nbr) < 100 then + stop + /* check is intentionally more complex than needed! */ + else if not (cnum($!nbr) > 999) then { + action(type="omfile" file="rsyslog.out.log" template="outfmt") + } +} -- cgit v1.2.3