diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-25 07:56:03 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-25 07:56:03 +0100 |
commit | 28b3703c95cb06642ff245f4d7e265c4591c128f (patch) | |
tree | d739e41dd9f2ba32a949d7496453f21baff0db28 | |
parent | 9e5b31fc44136dbcc1e443cfe7714e9daf97d844 (diff) | |
download | rsyslog-28b3703c95cb06642ff245f4d7e265c4591c128f.tar.gz rsyslog-28b3703c95cb06642ff245f4d7e265c4591c128f.tar.xz rsyslog-28b3703c95cb06642ff245f4d7e265c4591c128f.zip |
bugfix: potential segfault in dynafile cache
This bug was triggered by an open failure. The the cache was full and
a new entry needed to be placed inside it, a victim for eviction was
selected. That victim was freed, then the open of the new file tried. If
the open failed, the victim entry was still freed, and the function
exited. However, on next invocation and cache search, the victim entry
was used as if it were populated, most probably resulting in a segfault.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | tools/omfile.c | 2 |
2 files changed, 8 insertions, 1 deletions
@@ -2,6 +2,13 @@ Version 4.6.2 [v4-stable] (rgerhards), 2010-03-?? - new feature: "." action type added to support writing files to relative pathes (this is primarily meant as a debug aid) +- bugfix: potential segfault in dynafile cache + This bug was triggered by an open failure. The the cache was full and + a new entry needed to be placed inside it, a victim for eviction was + selected. That victim was freed, then the open of the new file tried. If + the open failed, the victim entry was still freed, and the function + exited. However, on next invocation and cache search, the victim entry + was used as if it were populated, most probably resulting in a segfault. - bugfix: race condition during directory creation If multiple files try to create a directory at (almost) the same time, some of them may fail. This is a data race and also exists with other diff --git a/tools/omfile.c b/tools/omfile.c index 91bcf0c2..2a14f45b 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -471,7 +471,7 @@ prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsgOpts) iOldest = 0; /* we assume the first element to be the oldest - that will change as we loop */ ttOldest = time(NULL) + 1; /* there must always be an older one */ for(i = 0 ; i < pData->iCurrCacheSize ; ++i) { - if(pCache[i] == NULL) { + if(pCache[i] == NULL || pCache[i]->pName == NULL) { if(iFirstFree == -1) iFirstFree = i; } else { /* got an element, let's see if it matches */ |