From cf1aaf14fa2bcb457a306d42723ed91a76df00f1 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 6 Oct 2011 11:42:47 +0200 Subject: fixed compiler warnings in tcpflood.c --- tests/tcpflood.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/tcpflood.c b/tests/tcpflood.c index 49b1e9e6..8485acbb 100644 --- a/tests/tcpflood.c +++ b/tests/tcpflood.c @@ -797,7 +797,7 @@ closeTLSSess(int i) # else /* NO TLS available */ static void initTLS(void) {} static void initTLSSess(int __attribute__((unused)) i) {} -static int sendTLS(int i, char *buf, int lenBuf) { return 0; } +static int sendTLS(int __attribute__((unused)) i, char __attribute__((unused)) *buf, int __attribute__((unused)) lenBuf) { return 0; } static void closeTLSSess(int __attribute__((unused)) i) {} # endif @@ -889,7 +889,8 @@ int main(int argc, char *argv[]) # if defined(ENABLE_GNUTLS) transport = TP_TLS; # else - fprintf(stderr, "compiled without TLS support!\n", optarg); + fprintf(stderr, "compiled without TLS support: " + "\"-Ttls\" not supported!\n"); exit(1); # endif } else { -- cgit v1.2.3 From cd5253fa82fdbd7529f76c9cec2130e1ccb210bb Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 7 Oct 2011 11:42:49 +0200 Subject: bugfix: imfile did invalid system call under some circumstances when a file that was to be monitored did not exist BUT the state file actually existed. Mostly a cosmetic issue. Root cause was incomplete error checking in stream.c; so patch may affect other code areas. --- ChangeLog | 4 ++++ plugins/imfile/imfile.c | 4 ++-- runtime/stream.c | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 11a75c26..b89429f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,10 @@ Version 5.8.6 [V5-stable] (rgerhards/al), 2011-??-?? - bugfix: omfile returns fatal error code for things that go really wrong previously, RS_RET_RESUME was returned, which lead to a loop inside the rule engine as omfile could not really recover. +- bugfix: imfile did invalid system call under some circumstances + when a file that was to be monitored did not exist BUT the state file + actually existed. Mostly a cosmetic issue. Root cause was incomplete + error checking in stream.c; so patch may affect other code areas. - bugfix: rsyslogd -v always said 64 atomics were not present thanks to mono_matsuko for the patch --------------------------------------------------------------------------- diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c index cac3a55d..40a41a98 100644 --- a/plugins/imfile/imfile.c +++ b/plugins/imfile/imfile.c @@ -147,10 +147,10 @@ openFile(fileInfo_t *pThis) /* check if the file exists */ if(stat((char*) pszSFNam, &stat_buf) == -1) { if(errno == ENOENT) { - /* currently no object! dbgoprint((obj_t*) pThis, "clean startup, no .si file found\n"); */ + dbgprintf("filemon %p: clean startup, no .si file found\n", pThis); ABORT_FINALIZE(RS_RET_FILE_NOT_FOUND); } else { - /* currently no object! dbgoprint((obj_t*) pThis, "error %d trying to access .si file\n", errno); */ + dbgprintf("filemon %p: error %d trying to access .si file\n", pThis, errno); ABORT_FINALIZE(RS_RET_IO_ERROR); } } diff --git a/runtime/stream.c b/runtime/stream.c index ae716815..0238d25e 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -1276,16 +1276,18 @@ static rsRetVal strmSeek(strm_t *pThis, off64_t offs) ISOBJ_TYPE_assert(pThis, strm); - if(pThis->fd == -1) - strmOpenFile(pThis); - else - strmFlushInternal(pThis); + if(pThis->fd == -1) { + CHKiRet(strmOpenFile(pThis)); + } else { + CHKiRet(strmFlushInternal(pThis)); + } long long i; DBGOPRINT((obj_t*) pThis, "file %d seek, pos %llu\n", pThis->fd, (long long unsigned) offs); i = lseek64(pThis->fd, offs, SEEK_SET); // TODO: check error! pThis->iCurrOffs = offs; /* we are now at *this* offset */ pThis->iBufPtr = 0; /* buffer invalidated */ +finalize_it: RETiRet; } -- cgit v1.2.3 From 4831a51f5a7c8e3821cb98bc21fb47204e5470c2 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 13 Oct 2011 08:04:40 +0200 Subject: bugfix: race condition when extracting program name and APPNAME could lead to invalid characters e.g. in dynamic file names --- ChangeLog | 4 +++- runtime/msg.c | 28 ++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b89429f6..67359a96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ --------------------------------------------------------------------------- -Version 5.8.6 [V5-stable] (rgerhards/al), 2011-??-?? +Version 5.8.6 [V5-stable] 2011-??-?? +- bugfix: race condition when extracting program name and APPNAME + could lead to invalid characters e.g. in dynamic file names - bugfix: imuxsock did no longer ignore message-provided timestamp, if so configured (the *default*). Lead to no longer sub-second timestamps. closes: http://bugzilla.adiscon.com/show_bug.cgi?id=281 diff --git a/runtime/msg.c b/runtime/msg.c index 7cc588b7..eb1e3ae4 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1873,8 +1873,18 @@ int getProgramNameLen(msg_t *pM, sbool bLockMutex) */ uchar *getProgramName(msg_t *pM, sbool bLockMutex) { - prepareProgramName(pM, bLockMutex); - return (pM->pCSProgName == NULL) ? UCHAR_CONSTANT("") : rsCStrGetSzStrNoNULL(pM->pCSProgName); + uchar *pszRet; + + if(bLockMutex == LOCK_MUTEX) + MsgUnlock(pM); + prepareProgramName(pM, MUTEX_ALREADY_LOCKED); + if(pM->pCSProgName == NULL) + pszRet = UCHAR_CONSTANT(""); + else + pszRet = rsCStrGetSzStrNoNULL(pM->pCSProgName); + if(bLockMutex == LOCK_MUTEX) + MsgUnlock(pM); + return pszRet; } @@ -1920,9 +1930,19 @@ static inline void prepareAPPNAME(msg_t *pM, sbool bLockMutex) */ char *getAPPNAME(msg_t *pM, sbool bLockMutex) { + uchar *pszRet; + assert(pM != NULL); - prepareAPPNAME(pM, bLockMutex); - return (pM->pCSAPPNAME == NULL) ? "" : (char*) rsCStrGetSzStrNoNULL(pM->pCSAPPNAME); + if(bLockMutex == LOCK_MUTEX) + MsgUnlock(pM); + prepareAPPNAME(pM, MUTEX_ALREADY_LOCKED); + if(pM->pCSAPPNAME == NULL) + pszRet = UCHAR_CONSTANT(""); + else + pszRet = rsCStrGetSzStrNoNULL(pM->pCSAPPNAME); + if(bLockMutex == LOCK_MUTEX) + MsgUnlock(pM); + return (char*)pszRet; } /* rgerhards, 2005-11-24 -- cgit v1.2.3 From d6a6666b66733e63255f806dd272a0b85e0f0c13 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 13 Oct 2011 08:15:54 +0200 Subject: bugfix: race condition when extracting structured data and PROCID same issue as previous commit for PROGNAME and APPNAME --- ChangeLog | 6 ++++-- runtime/msg.c | 24 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67359a96..a0878d75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,9 @@ --------------------------------------------------------------------------- Version 5.8.6 [V5-stable] 2011-??-?? -- bugfix: race condition when extracting program name and APPNAME - could lead to invalid characters e.g. in dynamic file names +- bugfix: race condition when extracting program name, APPNAME, structured + data and PROCID (RFC5424 fields) could lead to invalid characters e.g. + in dynamic file names or during forwarding (general malfunction of these + fields in templates, mostly under heavy load) - bugfix: imuxsock did no longer ignore message-provided timestamp, if so configured (the *default*). Lead to no longer sub-second timestamps. closes: http://bugzilla.adiscon.com/show_bug.cgi?id=281 diff --git a/runtime/msg.c b/runtime/msg.c index eb1e3ae4..0744edd5 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1605,9 +1605,19 @@ static inline int getPROCIDLen(msg_t *pM, sbool bLockMutex) */ char *getPROCID(msg_t *pM, sbool bLockMutex) { + uchar *pszRet; + ISOBJ_TYPE_assert(pM, msg); - preparePROCID(pM, bLockMutex); - return (pM->pCSPROCID == NULL) ? "-" : (char*) cstrGetSzStrNoNULL(pM->pCSPROCID); + if(bLockMutex == LOCK_MUTEX) + MsgUnlock(pM); + preparePROCID(pM, MUTEX_ALREADY_LOCKED); + if(pM->pCSPROCID == NULL) + pszRet = UCHAR_CONSTANT(""); + else + pszRet = rsCStrGetSzStrNoNULL(pM->pCSPROCID); + if(bLockMutex == LOCK_MUTEX) + MsgUnlock(pM); + return (char*) pszRet; } @@ -1834,7 +1844,15 @@ static int getStructuredDataLen(msg_t *pM) */ static inline char *getStructuredData(msg_t *pM) { - return (pM->pCSStrucData == NULL) ? "-" : (char*) rsCStrGetSzStrNoNULL(pM->pCSStrucData); + uchar *pszRet; + + MsgUnlock(pM); + if(pM->pCSStrucData == NULL) + pszRet = UCHAR_CONSTANT("-"); + else + pszRet = rsCStrGetSzStrNoNULL(pM->pCSStrucData); + MsgUnlock(pM); + return (char*) pszRet; } -- cgit v1.2.3