From 617a7aaa1dc4569e6c151a14889bffe808f984c5 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Tue, 31 Jul 2012 08:19:37 -0700 Subject: bugfix: DA queue fixed handling of bad queue files. --- ChangeLog | 4 ++++ runtime/queue.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d12e14c4..a081893b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,10 @@ Version 5.8.13 [V5-stable] 2012-06-?? - bugfix: randomized IP option header in omudpspoof caused problems closes: http://bugzilla.adiscon.com/show_bug.cgi?id=327 Thanks to Rick Brown for helping to test out the patch. +- bugfix: DA queue fixed handling of bad queue files. If old queue files + existed, they were not truncated when being reused. this could lead to + extra data being read from them and in consequence data format errors, + which could cause trouble to the queue handler. --------------------------------------------------------------------------- Version 5.8.12 [V5-stable] 2012-06-06 - add small delay (50ms) after sending shutdown message diff --git a/runtime/queue.c b/runtime/queue.c index 280ebd94..6a1cf446 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -707,7 +707,7 @@ static rsRetVal qConstructDisk(qqueue_t *pThis) CHKiRet(strm.SetbSync(pThis->tVars.disk.pWrite, pThis->bSyncQueueFiles)); CHKiRet(strm.SetDir(pThis->tVars.disk.pWrite, glbl.GetWorkDir(), strlen((char*)glbl.GetWorkDir()))); CHKiRet(strm.SetiMaxFiles(pThis->tVars.disk.pWrite, 10000000)); - CHKiRet(strm.SettOperationsMode(pThis->tVars.disk.pWrite, STREAMMODE_WRITE)); + CHKiRet(strm.SettOperationsMode(pThis->tVars.disk.pWrite, STREAMMODE_WRITE_TRUNC)); CHKiRet(strm.SetsType(pThis->tVars.disk.pWrite, STREAMTYPE_FILE_CIRCULAR)); CHKiRet(strm.ConstructFinalize(pThis->tVars.disk.pWrite)); -- cgit v1.2.3 From 4d01df57c2f378ceda3bcc400a9df5e50a0c007b Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 1 Aug 2012 10:14:37 +0200 Subject: bugfix: potential abort if output plugin logged message during shutdown note that none of the rsyslog-provided plugins does this Thanks to bodik and Rohit Prasad for alerting us on this bug and analyzing it. fixes: http://bugzilla.adiscon.com/show_bug.cgi?id=347 --- ChangeLog | 13 +++++++++---- tools/syslogd.c | 22 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a081893b..eb8230dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,10 +8,15 @@ Version 5.8.13 [V5-stable] 2012-06-?? - bugfix: randomized IP option header in omudpspoof caused problems closes: http://bugzilla.adiscon.com/show_bug.cgi?id=327 Thanks to Rick Brown for helping to test out the patch. -- bugfix: DA queue fixed handling of bad queue files. If old queue files - existed, they were not truncated when being reused. this could lead to - extra data being read from them and in consequence data format errors, - which could cause trouble to the queue handler. +- bugfix: DA queue fixed handling of bad queue files + If old queue files existed, they were not truncated when being reused. + This could lead to extra data being read from them and in consequence + data format errors, which could cause trouble to the queue handler. +- bugfix: potential abort if output plugin logged message during shutdown + note that none of the rsyslog-provided plugins does this + Thanks to bodik and Rohit Prasad for alerting us on this bug and + analyzing it. + fixes: http://bugzilla.adiscon.com/show_bug.cgi?id=347 --------------------------------------------------------------------------- Version 5.8.12 [V5-stable] 2012-06-06 - add small delay (50ms) after sending shutdown message diff --git a/tools/syslogd.c b/tools/syslogd.c index cbbb66bc..8fc1d1e1 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -725,11 +725,19 @@ submitMsg(msg_t *pMsg) ISOBJ_TYPE_assert(pMsg, msg); pRuleset = MsgGetRuleset(pMsg); - pQueue = (pRuleset == NULL) ? pMsgQueue : ruleset.GetRulesetQueue(pRuleset); + + /* if a plugin logs a message during shutdown, the queue may no longer exist */ + if(pQueue == NULL) { + DBGPRINTF("submitMsg() could not submit message - " + "queue does (no longer?) exist - ignored\n"); + FINALIZE; + } + MsgPrepareEnqueue(pMsg); qqueueEnqObj(pQueue, pMsg->flowCtlType, (void*) pMsg); +finalize_it: RETiRet; } @@ -750,12 +758,20 @@ multiSubmitMsg(multi_submit_t *pMultiSub) if(pMultiSub->nElem == 0) FINALIZE; + pRuleset = MsgGetRuleset(pMultiSub->ppMsgs[0]); + pQueue = (pRuleset == NULL) ? pMsgQueue : ruleset.GetRulesetQueue(pRuleset); + + /* if a plugin logs a message during shutdown, the queue may no longer exist */ + if(pQueue == NULL) { + DBGPRINTF("multiSubmitMsg() could not submit message - " + "queue does (no longer?) exist - ignored\n"); + FINALIZE; + } + for(i = 0 ; i < pMultiSub->nElem ; ++i) { MsgPrepareEnqueue(pMultiSub->ppMsgs[i]); } - pRuleset = MsgGetRuleset(pMultiSub->ppMsgs[0]); - pQueue = (pRuleset == NULL) ? pMsgQueue : ruleset.GetRulesetQueue(pRuleset); iRet = pQueue->MultiEnq(pQueue, pMultiSub); pMultiSub->nElem = 0; -- cgit v1.2.3 From 5d2a114743a06f1611980ae75d704b2af5ab97ed Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 1 Aug 2012 10:32:09 +0200 Subject: undo last queue patch - caused a regression some more elaborate patch is needed and will be provided --- ChangeLog | 4 ---- runtime/queue.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb8230dc..2efbaa8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,10 +8,6 @@ Version 5.8.13 [V5-stable] 2012-06-?? - bugfix: randomized IP option header in omudpspoof caused problems closes: http://bugzilla.adiscon.com/show_bug.cgi?id=327 Thanks to Rick Brown for helping to test out the patch. -- bugfix: DA queue fixed handling of bad queue files - If old queue files existed, they were not truncated when being reused. - This could lead to extra data being read from them and in consequence - data format errors, which could cause trouble to the queue handler. - bugfix: potential abort if output plugin logged message during shutdown note that none of the rsyslog-provided plugins does this Thanks to bodik and Rohit Prasad for alerting us on this bug and diff --git a/runtime/queue.c b/runtime/queue.c index 6a1cf446..280ebd94 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -707,7 +707,7 @@ static rsRetVal qConstructDisk(qqueue_t *pThis) CHKiRet(strm.SetbSync(pThis->tVars.disk.pWrite, pThis->bSyncQueueFiles)); CHKiRet(strm.SetDir(pThis->tVars.disk.pWrite, glbl.GetWorkDir(), strlen((char*)glbl.GetWorkDir()))); CHKiRet(strm.SetiMaxFiles(pThis->tVars.disk.pWrite, 10000000)); - CHKiRet(strm.SettOperationsMode(pThis->tVars.disk.pWrite, STREAMMODE_WRITE_TRUNC)); + CHKiRet(strm.SettOperationsMode(pThis->tVars.disk.pWrite, STREAMMODE_WRITE)); CHKiRet(strm.SetsType(pThis->tVars.disk.pWrite, STREAMTYPE_FILE_CIRCULAR)); CHKiRet(strm.ConstructFinalize(pThis->tVars.disk.pWrite)); -- cgit v1.2.3 From 46f7f10e4375553e6a94d7e51b604462808bbff1 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 1 Aug 2012 15:37:00 +0200 Subject: more elaborate debug logging for object deserializer --- runtime/obj.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/runtime/obj.c b/runtime/obj.c index f9afecd8..fda6051d 100644 --- a/runtime/obj.c +++ b/runtime/obj.c @@ -611,6 +611,8 @@ static rsRetVal objDeserializeProperty(var_t *pProp, strm_t *pStrm) number_t i; number_t iLen; uchar c; + int step = 0; /* which step was successful? */ + int64 offs; assert(pProp != NULL); @@ -631,13 +633,16 @@ static rsRetVal objDeserializeProperty(var_t *pProp, strm_t *pStrm) NEXTC; } CHKiRet(cstrFinalize(pProp->pcsName)); + step = 1; /* property type */ CHKiRet(objDeserializeNumber(&i, pStrm)); pProp->varType = i; + step = 2; /* size (needed for strings) */ CHKiRet(objDeserializeNumber(&iLen, pStrm)); + step = 3; /* we now need to deserialize the value */ switch(pProp->varType) { @@ -654,12 +659,46 @@ static rsRetVal objDeserializeProperty(var_t *pProp, strm_t *pStrm) dbgprintf("invalid VARTYPE %d\n", pProp->varType); break; } + step = 4; /* we should now be at the end of the line. So the next char must be \n */ NEXTC; if(c != '\n') ABORT_FINALIZE(RS_RET_INVALID_PROPFRAME); finalize_it: + if(Debug && iRet != RS_RET_OK) { + strm.GetCurrOffset(pStrm, &offs); + if(step == 0) { + dbgprintf("error %d deserializing property name, offset %lld, step %d\n", + iRet, offs, step); + } + if(step >= 1) { + dbgprintf("error property name: '%s'\n", rsCStrGetSzStrNoNULL(pProp->pcsName)); + } + if(step >= 2) { + dbgprintf("error var type: '%d'\n", pProp->varType); + } + if(step >= 3) { + dbgprintf("error len: '%d'\n", (int) iLen); + } + if(step >= 4) { + switch(pProp->varType) { + case VARTYPE_STR: + dbgprintf("error data string: '%s'\n", + rsCStrGetSzStrNoNULL(pProp->val.pStr)); + break; + case VARTYPE_NUMBER: + dbgprintf("error number: %d\n", (int) pProp->val.num); + break; + case VARTYPE_SYSLOGTIME: + dbgprintf("syslog time was successfully parsed (but " + "is not displayed\n"); + break; + default: + break; + } + } + } RETiRet; } -- cgit v1.2.3 From 9fb96ec34312b6da7b496db0b3d5eb86442fed06 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 1 Aug 2012 15:56:42 +0200 Subject: nitfix: remove quirck in new debug message code --- runtime/obj.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/runtime/obj.c b/runtime/obj.c index fda6051d..666dd6b0 100644 --- a/runtime/obj.c +++ b/runtime/obj.c @@ -668,10 +668,8 @@ static rsRetVal objDeserializeProperty(var_t *pProp, strm_t *pStrm) finalize_it: if(Debug && iRet != RS_RET_OK) { strm.GetCurrOffset(pStrm, &offs); - if(step == 0) { - dbgprintf("error %d deserializing property name, offset %lld, step %d\n", - iRet, offs, step); - } + dbgprintf("error %d deserializing property name, offset %lld, step %d\n", + iRet, offs, step); if(step >= 1) { dbgprintf("error property name: '%s'\n", rsCStrGetSzStrNoNULL(pProp->pcsName)); } -- cgit v1.2.3