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 /runtime/stream.c | |
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)
Diffstat (limited to 'runtime/stream.c')
-rw-r--r-- | runtime/stream.c | 3 |
1 files changed, 2 insertions, 1 deletions
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; |