Merge pull request #1398 from rgerhards/q-deserializer-seq-err

core: fix sequence error in msg object deserializer
This commit is contained in:
Rainer Gerhards 2017-02-11 11:23:31 +01:00 committed by GitHub
commit 33b7f1fefe
3 changed files with 44 additions and 6 deletions

View File

@ -1350,6 +1350,11 @@ MsgDeserialize(smsg_t * const pMsg, strm_t *pStrm)
reinitVar(pVar);
CHKiRet(objDeserializeProperty(pVar, pStrm));
}
if(isProp("pszStrucData")) {
MsgSetStructuredData(pMsg, (char*) rsCStrGetSzStrNoNULL(pVar->val.pStr));
reinitVar(pVar);
CHKiRet(objDeserializeProperty(pVar, pStrm));
}
if(isProp("json")) {
tokener = json_tokener_new();
pMsg->json = json_tokener_parse_ex(tokener, (char*)rsCStrGetSzStrNoNULL(pVar->val.pStr),
@ -1366,11 +1371,6 @@ MsgDeserialize(smsg_t * const pMsg, strm_t *pStrm)
reinitVar(pVar);
CHKiRet(objDeserializeProperty(pVar, pStrm));
}
if(isProp("pszStrucData")) {
MsgSetStructuredData(pMsg, (char*) rsCStrGetSzStrNoNULL(pVar->val.pStr));
reinitVar(pVar);
CHKiRet(objDeserializeProperty(pVar, pStrm));
}
if(isProp("pCSAPPNAME")) {
MsgSetAPPNAME(pMsg, (char*) rsCStrGetSzStrNoNULL(pVar->val.pStr));
reinitVar(pVar);
@ -1401,8 +1401,10 @@ MsgDeserialize(smsg_t * const pMsg, strm_t *pStrm)
* but on the other hand it works decently AND we will probably replace
* the whole persisted format soon in any case. -- rgerhards, 2012-11-06
*/
if(!isProp("offMSG"))
if(!isProp("offMSG")) {
DBGPRINTF("error property: %s\n", rsCStrGetSzStrNoNULL(pVar->pcsName));
ABORT_FINALIZE(RS_RET_DS_PROP_SEQ_ERR);
}
MsgSetMSGoffs(pMsg, pVar->val.num);
finalize_it:
if(pVar != NULL)

View File

@ -97,6 +97,7 @@ TESTS += \
daqueue-persist.sh \
daqueue-invld-qi.sh \
daqueue-dirty-shutdown.sh \
diskq-rfc5424.sh \
diskqueue.sh \
diskqueue-fsync.sh \
rulesetmultiqueue.sh \
@ -703,6 +704,7 @@ EXTRA_DIST= \
fieldtest.sh \
rsf_getenv.sh \
testsuites/rsf_getenv.conf \
diskq-rfc5424.sh \
diskqueue.sh \
testsuites/diskqueue.conf \
arrayqueue.sh \

34
tests/diskq-rfc5424.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# detect queue corruption based on invalid property bag ordering.
# Note: this mimics an issue actually seen in practice.
# Triggering condition: "json" property (message variables) are present
# and "structured-data" property is also present. Caused rsyslog to
# thrash the queue file, getting messages stuck in it and loosing all
# after the initial problem occurence.
# add 2017-02-08 by Rainer Gerhards, released under ASL 2.0
. $srcdir/diag.sh init
. $srcdir/diag.sh generate-conf
. $srcdir/diag.sh add-conf '
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="13514" ruleset="rs")
template(name="outfmt" type="string" string="%msg:F,58:2%\n")
ruleset(name="rs2" queue.type="disk" queue.filename="rs2_q"
queue.spoolDirectory="test-spool") {
set $!tmp=$msg;
action(type="omfile" file="rsyslog.out.log" template="outfmt")
}
ruleset(name="rs") {
set $!tmp=$msg;
call rs2
}
'
. $srcdir/diag.sh startup
. $srcdir/diag.sh tcpflood -m1000 -y
. $srcdir/diag.sh shutdown-when-empty
. $srcdir/diag.sh wait-shutdown
. $srcdir/diag.sh seq-check 0 999
. $srcdir/diag.sh exit