From d92ad440da788fea9f17bfa4b0185f12644bf714 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 22 Aug 2012 14:30:12 +0200 Subject: bugfix: multiple main queues with same queue file name were not detected This lead to queue file corruption. While the root cause is a config error, it is a bug that this important and hard to find config error was not detected by rsyslog. --- runtime/ruleset.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/ruleset.c b/runtime/ruleset.c index 8e241c8a..d608f3ad 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -500,6 +500,7 @@ debugPrintAll(void) static rsRetVal rulesetCreateQueue(void __attribute__((unused)) *pVal, int *pNewVal) { + uchar *rsname; DEFiRet; if(pCurrRuleset == NULL) { @@ -517,8 +518,9 @@ rulesetCreateQueue(void __attribute__((unused)) *pVal, int *pNewVal) if(pNewVal == 0) FINALIZE; /* if it is turned off, we do not need to change anything ;) */ - dbgprintf("adding a ruleset-specific \"main\" queue"); - CHKiRet(createMainQueue(&pCurrRuleset->pQueue, UCHAR_CONSTANT("ruleset"))); + rsname = (pCurrRuleset->pszName == NULL) ? (uchar*) "[NONAME]" : pCurrRuleset->pszName; + DBGPRINTF("adding a ruleset-specific \"main\" queue for ruleset '%s'\n", rsname); + CHKiRet(createMainQueue(&pCurrRuleset->pQueue, rsname)); finalize_it: RETiRet; -- cgit From 9faf2240c4a8f09f3f6c2c9bbd47e48520524e03 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 22 Aug 2012 15:29:02 +0200 Subject: changed TRUE/FALSE to RSTRUE/RSFALSE This is done to prevent name claches with libraries. --- runtime/modules.c | 8 ++++---- runtime/parser.c | 20 ++++++++++---------- runtime/srutils.c | 8 +++----- runtime/stream.c | 4 ++-- runtime/syslogd-types.h | 5 +++-- runtime/wti.c | 4 ++-- runtime/wtp.h | 4 ++-- 7 files changed, 26 insertions(+), 27 deletions(-) (limited to 'runtime') diff --git a/runtime/modules.c b/runtime/modules.c index b353e983..45788ef7 100644 --- a/runtime/modules.c +++ b/runtime/modules.c @@ -498,11 +498,11 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_ /* check some features */ localRet = pNew->isCompatibleWithFeature(sFEATUREAutomaticSanitazion); if(localRet == RS_RET_OK){ - CHKiRet(parser.SetDoSanitazion(pParser, TRUE)); + CHKiRet(parser.SetDoSanitazion(pParser, RSTRUE)); } localRet = pNew->isCompatibleWithFeature(sFEATUREAutomaticPRIParsing); if(localRet == RS_RET_OK){ - CHKiRet(parser.SetDoPRIParsing(pParser, TRUE)); + CHKiRet(parser.SetDoPRIParsing(pParser, RSTRUE)); } CHKiRet(parser.SetName(pParser, pName)); @@ -787,9 +787,9 @@ Load(uchar *pModName) if(iModNameLen > 3 && !strcmp((char *) pModName + iModNameLen - 3, ".so")) { iModNameLen -= 3; - bHasExtension = TRUE; + bHasExtension = RSTRUE; } else - bHasExtension = FALSE; + bHasExtension = RSFALSE; pModInfo = GetNxt(NULL); while(pModInfo != NULL) { diff --git a/runtime/parser.c b/runtime/parser.c index 300db1e0..180814cf 100644 --- a/runtime/parser.c +++ b/runtime/parser.c @@ -311,7 +311,7 @@ SanitizeMsg(msg_t *pMsg) size_t iDst; size_t iMaxLine; size_t maxDest; - sbool bUpdatedLen = FALSE; + sbool bUpdatedLen = RSFALSE; uchar szSanBuf[32*1024]; /* buffer used for sanitizing a string */ assert(pMsg != NULL); @@ -326,7 +326,7 @@ SanitizeMsg(msg_t *pMsg) */ if(pszMsg[lenMsg-1] == '\0') { DBGPRINTF("dropped NUL at very end of message\n"); - bUpdatedLen = TRUE; + bUpdatedLen = RSTRUE; lenMsg--; } @@ -339,7 +339,7 @@ SanitizeMsg(msg_t *pMsg) DBGPRINTF("dropped LF at very end of message (DropTrailingLF is set)\n"); lenMsg--; pszMsg[lenMsg] = '\0'; - bUpdatedLen = TRUE; + bUpdatedLen = RSTRUE; } /* it is much quicker to sweep over the message and see if it actually @@ -370,7 +370,7 @@ SanitizeMsg(msg_t *pMsg) } if(!bNeedSanitize) { - if(bUpdatedLen == TRUE) + if(bUpdatedLen == RSTRUE) MsgSetRawMsgSize(pMsg, lenMsg); FINALIZE; } @@ -508,17 +508,17 @@ ParseMsg(msg_t *pMsg) DBGPRINTF("parse using parser list %p%s.\n", pParserList, (pParserList == pDfltParsLst) ? " (the default list)" : ""); - bIsSanitized = FALSE; - bPRIisParsed = FALSE; + bIsSanitized = RSFALSE; + bPRIisParsed = RSFALSE; while(pParserList != NULL) { pParser = pParserList->pParser; - if(pParser->bDoSanitazion && bIsSanitized == FALSE) { + if(pParser->bDoSanitazion && bIsSanitized == RSFALSE) { CHKiRet(SanitizeMsg(pMsg)); - if(pParser->bDoPRIParsing && bPRIisParsed == FALSE) { + if(pParser->bDoPRIParsing && bPRIisParsed == RSFALSE) { CHKiRet(ParsePRI(pMsg)); - bPRIisParsed = TRUE; + bPRIisParsed = RSTRUE; } - bIsSanitized = TRUE; + bIsSanitized = RSTRUE; } localRet = pParser->pModule->mod.pm.parse(pMsg); dbgprintf("Parser '%s' returned %d\n", pParser->pName, localRet); diff --git a/runtime/srutils.c b/runtime/srutils.c index a473c83e..f420c0f7 100644 --- a/runtime/srutils.c +++ b/runtime/srutils.c @@ -41,8 +41,6 @@ #include #include #include -#define TRUE 1 -#define FALSE 0 #include "srUtils.h" #include "obj.h" @@ -128,11 +126,11 @@ rsRetVal srUtilItoA(char *pBuf, int iLenBuf, number_t iToConv) if(iToConv < 0) { - bIsNegative = TRUE; + bIsNegative = RSTRUE; iToConv *= -1; } else - bIsNegative = FALSE; + bIsNegative = RSFALSE; /* first generate a string with the digits in the reverse direction */ i = 0; @@ -148,7 +146,7 @@ rsRetVal srUtilItoA(char *pBuf, int iLenBuf, number_t iToConv) return RS_RET_PROVIDED_BUFFER_TOO_SMALL; /* then move it to the right direction... */ - if(bIsNegative == TRUE) + if(bIsNegative == RSTRUE) *pBuf++ = '-'; while(i >= 0) *pBuf++ = szBuf[i--]; diff --git a/runtime/stream.c b/runtime/stream.c index 6b88d3f4..9645a3fe 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -1172,7 +1172,7 @@ doZipWrite(strm_t *pThis, uchar *pBuf, size_t lenBuf) { z_stream zstrm; int zRet; /* zlib return state */ - sbool bzInitDone = FALSE; + sbool bzInitDone = RSFALSE; DEFiRet; assert(pThis != NULL); assert(pBuf != NULL); @@ -1188,7 +1188,7 @@ doZipWrite(strm_t *pThis, uchar *pBuf, size_t lenBuf) DBGPRINTF("error %d returned from zlib/deflateInit2()\n", zRet); ABORT_FINALIZE(RS_RET_ZLIB_ERR); } - bzInitDone = TRUE; + bzInitDone = RSTRUE; /* now doing the compression */ zstrm.next_in = (Bytef*) pBuf; /* as of zlib doc, this must be set BEFORE DeflateInit2 */ diff --git a/runtime/syslogd-types.h b/runtime/syslogd-types.h index 30ce896a..6947a110 100644 --- a/runtime/syslogd-types.h +++ b/runtime/syslogd-types.h @@ -31,8 +31,9 @@ #include #endif -#define FALSE 0 -#define TRUE 1 +/* we use RSTRUE/FALSE to prevent name claches with other packages */ +#define RSFALSE 0 +#define RSTRUE 1 #ifdef UT_NAMESIZE # define UNAMESZ UT_NAMESIZE /* length of a login name */ diff --git a/runtime/wti.c b/runtime/wti.c index e44086af..7b88c3eb 100644 --- a/runtime/wti.c +++ b/runtime/wti.c @@ -86,7 +86,7 @@ rsRetVal wtiSetAlwaysRunning(wti_t *pThis) { ISOBJ_TYPE_assert(pThis, wti); - pThis->bAlwaysRunning = TRUE; + pThis->bAlwaysRunning = RSTRUE; return RS_RET_OK; } @@ -198,7 +198,7 @@ wtiConstructFinalize(wti_t *pThis) dbgprintf("%s: finalizing construction of worker instance data\n", wtiGetDbgHdr(pThis)); /* initialize our thread instance descriptor (no concurrency here) */ - pThis->bIsRunning = FALSE; + pThis->bIsRunning = RSFALSE; /* we now alloc the array for user pointers. We obtain the max from the queue itself. */ CHKiRet(pThis->pWtp->pfGetDeqBatchSize(pThis->pWtp->pUsr, &iDeqBatchSize)); diff --git a/runtime/wtp.h b/runtime/wtp.h index 7e24ec82..25992f7f 100644 --- a/runtime/wtp.h +++ b/runtime/wtp.h @@ -27,8 +27,8 @@ #include "atomic.h" /* states for worker threads. */ -#define WRKTHRD_STOPPED FALSE -#define WRKTHRD_RUNNING TRUE +#define WRKTHRD_STOPPED RSFALSE +#define WRKTHRD_RUNNING RSTRUE /* possible states of a worker thread pool */ -- cgit From 06cf49e5a6cd25abe7c77fe3df97b7f87b9c576e Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 22 Aug 2012 15:32:32 +0200 Subject: nit: forward-compatible default ruleset name as used in next version --- runtime/ruleset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/ruleset.c b/runtime/ruleset.c index d608f3ad..14dc4c74 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -518,7 +518,7 @@ rulesetCreateQueue(void __attribute__((unused)) *pVal, int *pNewVal) if(pNewVal == 0) FINALIZE; /* if it is turned off, we do not need to change anything ;) */ - rsname = (pCurrRuleset->pszName == NULL) ? (uchar*) "[NONAME]" : pCurrRuleset->pszName; + rsname = (pCurrRuleset->pszName == NULL) ? (uchar*) "[ruleset]" : pCurrRuleset->pszName; DBGPRINTF("adding a ruleset-specific \"main\" queue for ruleset '%s'\n", rsname); CHKiRet(createMainQueue(&pCurrRuleset->pQueue, rsname)); -- cgit From c8d66987a2aff47d5cd8d1dc811893ce91c8410d Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 22 Aug 2012 16:54:41 +0200 Subject: small bugfix: stream timeout API use was incorrect Thanks to Andre Lorbach for mentioning this. --- runtime/stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/stream.c b/runtime/stream.c index d6ee1e39..742799d2 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -1010,6 +1010,7 @@ asyncWriterThread(void *pPtr) struct timespec t; sbool bTimedOut = 0; strm_t *pThis = (strm_t*) pPtr; + int err; ISOBJ_TYPE_assert(pThis, strm); BEGINfunc @@ -1036,8 +1037,7 @@ asyncWriterThread(void *pPtr) bTimedOut = 0; timeoutComp(&t, pThis->iFlushInterval * 1000); /* *1000 millisconds */ if(pThis->bDoTimedWait) { - if(pthread_cond_timedwait(&pThis->notEmpty, &pThis->mut, &t) != 0) { - int err = errno; + if((err = pthread_cond_timedwait(&pThis->notEmpty, &pThis->mut, &t)) != 0) { if(err == ETIMEDOUT) { bTimedOut = 1; } else { -- cgit From 1824ab8d98b983402315b86954a7ad160b43b508 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Sat, 25 Aug 2012 11:21:26 +0200 Subject: change template.[ch] to ASL 2.0, removing a GPLv3-only patch see template.c file header for details Note that this functionality was almost never used in practice --- runtime/msg.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime') diff --git a/runtime/msg.c b/runtime/msg.c index f9acb842..0d22b29a 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -2547,11 +2547,13 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, ++pFld; /* skip to field terminator */ if(*pFld == pTpe->data.field.field_delim) { ++pFld; /* eat it */ +#ifdef STRICT_GPLV3 if (pTpe->data.field.field_expand != 0) { while (*pFld == pTpe->data.field.field_delim) { ++pFld; } } +#endif ++iCurrFld; } } -- cgit