diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-19 07:41:04 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-19 07:41:04 +0100 |
commit | 9cdcba0bdc8b8d2df8d06784f3c4f0066c90fd40 (patch) | |
tree | 7ed904fced77fb9b853bef5fdcc3f1550bfce000 | |
parent | 3e0578605f7df8427aa5b70c2b4396504113fafc (diff) | |
download | rsyslog-9cdcba0bdc8b8d2df8d06784f3c4f0066c90fd40.tar.gz rsyslog-9cdcba0bdc8b8d2df8d06784f3c4f0066c90fd40.tar.xz rsyslog-9cdcba0bdc8b8d2df8d06784f3c4f0066c90fd40.zip |
bugfix: invalid buffer write in (file) stream class
currently being accessed buffer could be overwritten with new data.
While this probably did not cause access violations, it could case loss
and/or duplication of some data (definitely a race with no deterministic
outcome)
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | runtime/stream.c | 3 |
2 files changed, 7 insertions, 1 deletions
@@ -6,6 +6,11 @@ Version 4.6.2 [v4-stable] (rgerhards), 2010-03-?? to ease migration from syslog-ng. See property replacer doc for details. [backport from 5.5.3 because urgently needed by some] - improved testbench +- bugfix: invalid buffer write in (file) stream class + currently being accessed buffer could be overwritten with new data. + While this probably did not cause access violations, it could case loss + and/or duplication of some data (definitely a race with no deterministic + outcome) - bugfix: potential hang condition during filestream close predicate was not properly checked when waiting for the background file writer diff --git a/runtime/stream.c b/runtime/stream.c index 88606db7..e2f6623e 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -863,7 +863,8 @@ doAsyncWriteInternal(strm_t *pThis, size_t lenBuf) DEFiRet; ISOBJ_TYPE_assert(pThis, strm); - while(pThis->iCnt >= STREAM_ASYNC_NUMBUFS) + /* the -1 below is important, because we need one buffer for the main thread! */ + while(pThis->iCnt >= STREAM_ASYNC_NUMBUFS - 1) d_pthread_cond_wait(&pThis->notFull, &pThis->mut); pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].lenBuf = lenBuf; |