From 9cfa072caa0ba1863c89ae6b41d1c5838b9a42b0 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 19 Jan 2010 15:15:22 +0100 Subject: bugfix: blanks inside file names did not terminate file name parsing. This could reslult in the whole rest of a line (including comments) to be treated as file name in "write to file" actions. Thanks to Jack for reporting this issue. --- ChangeLog | 4 ++++ runtime/conf.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c58d5b78..837b1cb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ --------------------------------------------------------------------------- Version 4.5.8 [v4-beta] (rgerhards), 2010-01-?? +- bugfix: blanks inside file names did not terminate file name parsing. + This could reslult in the whole rest of a line (including comments) + to be treated as file name in "write to file" actions. + Thanks to Jack for reporting this issue. - bugfix: rsyslog hang when writing to a named pipe which nobody was reading. Thanks to Michael Biebl for reporting this bug. - bugfix: memory leak when sending messages in zip-compressed format diff --git a/runtime/conf.c b/runtime/conf.c index 83ed2e9b..b92664a1 100644 --- a/runtime/conf.c +++ b/runtime/conf.c @@ -568,6 +568,7 @@ finalize_it: * rgerhards, 2007-07-25 * updated to include OMSR pointer -- rgerhards, 2007-07-27 * updated to include template name -- rgerhards, 2008-03-28 + * rgerhards, 2010-01-19: file names end at the first space */ rsRetVal cflineParseFileName(uchar* p, uchar *pFileName, omodStringRequest_t *pOMSR, int iEntry, int iTplOpts, uchar *pszTpl) @@ -580,7 +581,7 @@ cflineParseFileName(uchar* p, uchar *pFileName, omodStringRequest_t *pOMSR, int pName = pFileName; i = 1; /* we start at 1 so that we reseve space for the '\0'! */ - while(*p && *p != ';' && i < MAXFNAME) { + while(*p && *p != ';' && *p != ' ' && i < MAXFNAME) { *pName++ = *p++; ++i; } -- cgit v1.2.3 From bd03b86c6322c82fc9f667122f4365e339f28ccc Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 19 Jan 2010 15:49:26 +0100 Subject: bugfix: -d did not enable display of debug messages regression from introduction of "debug on demand" mode Thanks to Michael Biebl for reporting this bug --- ChangeLog | 3 +++ tools/syslogd.c | 1 + 2 files changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 837b1cb4..29383818 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ --------------------------------------------------------------------------- Version 4.5.8 [v4-beta] (rgerhards), 2010-01-?? +- bugfix: -d did not enable display of debug messages + regression from introduction of "debug on demand" mode + Thanks to Michael Biebl for reporting this bug - bugfix: blanks inside file names did not terminate file name parsing. This could reslult in the whole rest of a line (including comments) to be treated as file name in "write to file" actions. diff --git a/tools/syslogd.c b/tools/syslogd.c index 3dd51adf..ab8f015d 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -3203,6 +3203,7 @@ int realMain(int argc, char **argv) iCompatibilityMode = atoi(optarg); break; case 'd': /* debug - must be handled now, so that debug is active during init! */ + debugging_on = 1; Debug = 1; break; case 'e': /* log every message (no repeat message supression) */ -- cgit v1.2.3 From ca8884d85d4ca35ebc8f410f78716ddb46ad86bb Mon Sep 17 00:00:00 2001 From: varmojfekoj Date: Tue, 26 Jan 2010 11:30:06 +0100 Subject: bugfixes for potential segfaults during queue shutdown (bugs require certain non-standard settings to appear) Signed-off-by: Rainer Gerhards --- runtime/queue.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/runtime/queue.c b/runtime/queue.c index 4e017e84..18418df0 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -853,9 +853,11 @@ static rsRetVal qDestructDisk(qqueue_t *pThis) DEFiRet; ASSERT(pThis != NULL); - - strmDestruct(&pThis->tVars.disk.pWrite); - strmDestruct(&pThis->tVars.disk.pRead); + + if (pThis->tVars.disk.pWrite != NULL) + strmDestruct(&pThis->tVars.disk.pWrite); + if (pThis->tVars.disk.pRead != NULL) + strmDestruct(&pThis->tVars.disk.pRead); RETiRet; } @@ -1209,7 +1211,7 @@ static rsRetVal qqueueShutdownWorkers(qqueue_t *pThis) /* we need to re-aquire the mutex for the next check in this case! */ BEGIN_MTX_PROTECTED_OPERATIONS(pThis->mut, LOCK_MUTEX); /* some workers may be running in parallel! */ } - if(pThis->bIsDA && wtpGetCurNumWrkr(pThis->pWtpDA, LOCK_MUTEX) > 0) { + if(pThis->bRunsDA && wtpGetCurNumWrkr(pThis->pWtpDA, LOCK_MUTEX) > 0) { /* and now the same for the DA queue */ END_MTX_PROTECTED_OPERATIONS(pThis->mut); dbgoprint((obj_t*) pThis, "trying immediate shutdown of DA workers\n"); @@ -1662,7 +1664,7 @@ qqueueChkStopWrkrDA(qqueue_t *pThis) if(pThis->bEnqOnly) { bStopWrkr = 1; } else { - if(pThis->bRunsDA) { + if(pThis->bRunsDA == 2) { ASSERT(pThis->pqDA != NULL); if( pThis->pqDA->bEnqOnly && pThis->pqDA->sizeOnDiskMax > 0 @@ -1917,7 +1919,8 @@ static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint) pThis->bNeedDelQIF = 0; } /* indicate spool file needs to be deleted */ - CHKiRet(strmSetbDeleteOnClose(pThis->tVars.disk.pRead, 1)); + if (pThis->tVars.disk.pRead != NULL) + CHKiRet(strmSetbDeleteOnClose(pThis->tVars.disk.pRead, 1)); FINALIZE; /* nothing left to do, so be happy */ } @@ -1951,13 +1954,15 @@ static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint) } /* now persist the stream info */ - CHKiRet(strmSerialize(pThis->tVars.disk.pWrite, psQIF)); - CHKiRet(strmSerialize(pThis->tVars.disk.pRead, psQIF)); + if (pThis->tVars.disk.pWrite != NULL) + CHKiRet(strmSerialize(pThis->tVars.disk.pWrite, psQIF)); + if (pThis->tVars.disk.pRead != NULL) + CHKiRet(strmSerialize(pThis->tVars.disk.pRead, psQIF)); /* tell the input file object that it must not delete the file on close if the queue * is non-empty - but only if we are not during a simple checkpoint */ - if(bIsCheckpoint != QUEUE_CHECKPOINT) { + if(bIsCheckpoint != QUEUE_CHECKPOINT && pThis->tVars.disk.pRead != NULL) { CHKiRet(strmSetbDeleteOnClose(pThis->tVars.disk.pRead, 0)); } -- cgit v1.2.3 From 8a3a6f4deb76218f24e79380db30904eef1feded Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 26 Jan 2010 11:38:21 +0100 Subject: did some adoptions necessary to use the bugfix with v4-beta code base --- runtime/queue.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/queue.c b/runtime/queue.c index 33fb4c0f..9d7a9058 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -860,9 +860,9 @@ static rsRetVal qDestructDisk(qqueue_t *pThis) ASSERT(pThis != NULL); if (pThis->tVars.disk.pWrite != NULL) - strmDestruct(&pThis->tVars.disk.pWrite); + strm.Destruct(&pThis->tVars.disk.pWrite); if (pThis->tVars.disk.pRead != NULL) - strmDestruct(&pThis->tVars.disk.pRead); + strm.Destruct(&pThis->tVars.disk.pRead); RETiRet; } @@ -1924,7 +1924,7 @@ static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint) } /* indicate spool file needs to be deleted */ if (pThis->tVars.disk.pRead != NULL) - CHKiRet(strmSetbDeleteOnClose(pThis->tVars.disk.pRead, 1)); + CHKiRet(strm.SetbDeleteOnClose(pThis->tVars.disk.pRead, 1)); FINALIZE; /* nothing left to do, so be happy */ } @@ -1959,15 +1959,15 @@ static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint) /* now persist the stream info */ if (pThis->tVars.disk.pWrite != NULL) - CHKiRet(strmSerialize(pThis->tVars.disk.pWrite, psQIF)); + CHKiRet(strm.Serialize(pThis->tVars.disk.pWrite, psQIF)); if (pThis->tVars.disk.pRead != NULL) - CHKiRet(strmSerialize(pThis->tVars.disk.pRead, psQIF)); + CHKiRet(strm.Serialize(pThis->tVars.disk.pRead, psQIF)); /* tell the input file object that it must not delete the file on close if the queue * is non-empty - but only if we are not during a simple checkpoint */ if(bIsCheckpoint != QUEUE_CHECKPOINT && pThis->tVars.disk.pRead != NULL) { - CHKiRet(strmSetbDeleteOnClose(pThis->tVars.disk.pRead, 0)); + CHKiRet(strm.SetbDeleteOnClose(pThis->tVars.disk.pRead, 0)); } /* we have persisted the queue object. So whenever it comes to an empty queue, -- cgit v1.2.3 From 7d098f14cba4f31dec7d92136183ebd0ccf7e1d0 Mon Sep 17 00:00:00 2001 From: varmojfekoj Date: Tue, 26 Jan 2010 11:54:33 +0100 Subject: bugfix: potential segfault on queue shutdown Signed-off-by: Rainer Gerhards --- ChangeLog | 2 ++ runtime/queue.c | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 116a2ce6..33ae5ad6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ Version 4.4.3 [v4-stable] (rgerhards), 2009-10-?? This was a regression from the time() optimizations done in v4. Bug tracker: http://bugzilla.adiscon.com/show_bug.cgi?id=143 Thanks to Klaus Tachtler for reporting this bug. +- bugfix: potential segfault on queue shutdown + Thanks to varmojfekoj for the patch. - bugfix: potential hang condition on queue shutdown [imported from v3-stable] - bugfix: segfault on startup when -q or -Q option was given diff --git a/runtime/queue.c b/runtime/queue.c index 4e017e84..18418df0 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -853,9 +853,11 @@ static rsRetVal qDestructDisk(qqueue_t *pThis) DEFiRet; ASSERT(pThis != NULL); - - strmDestruct(&pThis->tVars.disk.pWrite); - strmDestruct(&pThis->tVars.disk.pRead); + + if (pThis->tVars.disk.pWrite != NULL) + strmDestruct(&pThis->tVars.disk.pWrite); + if (pThis->tVars.disk.pRead != NULL) + strmDestruct(&pThis->tVars.disk.pRead); RETiRet; } @@ -1209,7 +1211,7 @@ static rsRetVal qqueueShutdownWorkers(qqueue_t *pThis) /* we need to re-aquire the mutex for the next check in this case! */ BEGIN_MTX_PROTECTED_OPERATIONS(pThis->mut, LOCK_MUTEX); /* some workers may be running in parallel! */ } - if(pThis->bIsDA && wtpGetCurNumWrkr(pThis->pWtpDA, LOCK_MUTEX) > 0) { + if(pThis->bRunsDA && wtpGetCurNumWrkr(pThis->pWtpDA, LOCK_MUTEX) > 0) { /* and now the same for the DA queue */ END_MTX_PROTECTED_OPERATIONS(pThis->mut); dbgoprint((obj_t*) pThis, "trying immediate shutdown of DA workers\n"); @@ -1662,7 +1664,7 @@ qqueueChkStopWrkrDA(qqueue_t *pThis) if(pThis->bEnqOnly) { bStopWrkr = 1; } else { - if(pThis->bRunsDA) { + if(pThis->bRunsDA == 2) { ASSERT(pThis->pqDA != NULL); if( pThis->pqDA->bEnqOnly && pThis->pqDA->sizeOnDiskMax > 0 @@ -1917,7 +1919,8 @@ static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint) pThis->bNeedDelQIF = 0; } /* indicate spool file needs to be deleted */ - CHKiRet(strmSetbDeleteOnClose(pThis->tVars.disk.pRead, 1)); + if (pThis->tVars.disk.pRead != NULL) + CHKiRet(strmSetbDeleteOnClose(pThis->tVars.disk.pRead, 1)); FINALIZE; /* nothing left to do, so be happy */ } @@ -1951,13 +1954,15 @@ static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint) } /* now persist the stream info */ - CHKiRet(strmSerialize(pThis->tVars.disk.pWrite, psQIF)); - CHKiRet(strmSerialize(pThis->tVars.disk.pRead, psQIF)); + if (pThis->tVars.disk.pWrite != NULL) + CHKiRet(strmSerialize(pThis->tVars.disk.pWrite, psQIF)); + if (pThis->tVars.disk.pRead != NULL) + CHKiRet(strmSerialize(pThis->tVars.disk.pRead, psQIF)); /* tell the input file object that it must not delete the file on close if the queue * is non-empty - but only if we are not during a simple checkpoint */ - if(bIsCheckpoint != QUEUE_CHECKPOINT) { + if(bIsCheckpoint != QUEUE_CHECKPOINT && pThis->tVars.disk.pRead != NULL) { CHKiRet(strmSetbDeleteOnClose(pThis->tVars.disk.pRead, 0)); } -- cgit v1.2.3