Merge pull request #5978 from rsyslog/codex/investigate-csl-subtree-with-omfwd-issue

template: fix missing lenStr in subtree templates
This commit is contained in:
Rainer Gerhards 2025-08-25 16:54:57 +02:00 committed by GitHub
commit 19c218460e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 7 deletions

View File

@ -154,6 +154,7 @@ rsRetVal tplToString(struct template *__restrict__ const pTpl,
if (iLenVal >= (rs_size_t)iparam->lenBuf) /* we reserve one char for the final \0! */
CHKiRet(ExtendBuf(iparam, iLenVal + 1));
memcpy(iparam->param, pVal, iLenVal + 1);
iparam->lenStr = iLenVal;
FINALIZE;
}

View File

@ -215,6 +215,7 @@ TESTS += \
omfwd-lb-2target-one_fail.sh \
omfwd-tls-invalid-permitExpiredCerts.sh \
omfwd-keepalive.sh \
omfwd-subtree-tpl.sh \
omusrmsg-errmsg-no-params.sh \
omusrmsg-noabort.sh \
omfile-module-params.sh \
@ -239,7 +240,7 @@ TESTS += \
privdropabortonidfail.sh \
privdropabortonidfaillegacy.sh \
json-nonstring.sh \
json-onempty-at-end.sh \
json-onempty-at-end.sh \
template-json.sh \
template-pure-json.sh \
template-pos-from-to.sh \
@ -2243,12 +2244,13 @@ EXTRA_DIST= \
omfwd-lb-2target-basic.sh \
omfwd-lb-2target-impstats.sh \
omfwd-lb-2target-retry.sh \
omfwd-lb-2target-one_fail.sh \
omfwd-tls-invalid-permitExpiredCerts.sh \
omfwd-keepalive.sh \
omfwd_fast_imuxsock.sh \
omfile_hup-vg.sh \
omsendertrack-basic.sh \
omfwd-lb-2target-one_fail.sh \
omfwd-tls-invalid-permitExpiredCerts.sh \
omfwd-keepalive.sh \
omfwd-subtree-tpl.sh \
omfwd_fast_imuxsock.sh \
omfile_hup-vg.sh \
omsendertrack-basic.sh \
omsendertrack-basic-vg.sh \
omsendertrack-statefile.sh \
omsendertrack-statefile-vg.sh \

28
tests/omfwd-subtree-tpl.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
# Verify omfwd forwards messages when using subtree-type templates
unset RSYSLOG_DYNNAME
. ${srcdir:=.}/diag.sh init
generate_conf
add_conf '
$MainMsgQueueTimeoutShutdown 10000
template(name="csl-subtree" type="subtree" subtree="$!csl")
if $msg contains "msgnum:" then {
set $!csl!foo = "bar";
action(type="omfwd" template="csl-subtree"
target="127.0.0.1" port="'$TCPFLOOD_PORT'" protocol="tcp")
}
'
./minitcpsrv -t127.0.0.1 -p$TCPFLOOD_PORT -f $RSYSLOG_OUT_LOG &
BGPROCESS=$!
startup
injectmsg 0 1
shutdown_when_empty
wait_shutdown
content_check '{ "foo": "bar" }' "$RSYSLOG_OUT_LOG"
exit_test