summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-09-10 15:04:08 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-09-10 15:04:08 +0200
commit78e9c7c4d2c4ec09cce403066f09a5a7e08e994e (patch)
tree6387a9dbcc871ad862cfd94a7e80fdf7f77a8481 /runtime
parenteb704286810bfd558b5fe43c1a50837c1b61f62c (diff)
downloadrsyslog-78e9c7c4d2c4ec09cce403066f09a5a7e08e994e.tar.gz
rsyslog-78e9c7c4d2c4ec09cce403066f09a5a7e08e994e.tar.xz
rsyslog-78e9c7c4d2c4ec09cce403066f09a5a7e08e994e.zip
bugfix: repeated messages were incorrectly processed
this could lead to loss of the repeated message content. As a side- effect, it could probably also be possible that some segfault occurs (quite unlikely). The root cause was that some counters introduced during the malloc optimizations were not properly duplicated in MsgDup(). Note that repeated message processing is not enabled by default.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/msg.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index de298871..2a370618 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -864,13 +864,17 @@ msg_t* MsgDup(msg_t* pOld)
pNew->iProtocolVersion = pOld->iProtocolVersion;
pNew->ttGenTime = pOld->ttGenTime;
pNew->offMSG = pOld->offMSG;
+ pNew->iLenRawMsg = pOld->iLenRawMsg;
+ pNew->iLenMSG = pOld->iLenMSG;
+ pNew->iLenTAG = pOld->iLenTAG;
+ pNew->iLenHOSTNAME = pOld->iLenHOSTNAME;
if(pOld->pRcvFrom != NULL) {
pNew->pRcvFrom = pOld->pRcvFrom;
prop.AddRef(pNew->pRcvFrom);
}
if(pOld->pRcvFromIP != NULL) {
pNew->pRcvFromIP = pOld->pRcvFromIP;
- prop.AddRef(pNew->pRcvFromIP); /* XXX */
+ prop.AddRef(pNew->pRcvFromIP);
}
if(pOld->pInputName != NULL) {
pNew->pInputName = pOld->pInputName;
@@ -1972,10 +1976,11 @@ rsRetVal MsgReplaceMSG(msg_t *pThis, uchar* pszMSG, int lenMSG)
lenNew = pThis->iLenRawMsg + lenMSG - pThis->iLenMSG;
if(lenMSG > pThis->iLenMSG && lenNew >= CONF_RAWMSG_BUFSIZE) {
- /* we have lost and need to alloc a new buffer ;) */
+ /* we have lost our "bet" and need to alloc a new buffer ;) */
CHKmalloc(bufNew = malloc(lenNew + 1));
memcpy(bufNew, pThis->pszRawMsg, pThis->offMSG);
- free(pThis->pszRawMsg);
+ if(pThis->pszRawMsg != pThis->szRawMsg)
+ free(pThis->pszRawMsg);
pThis->pszRawMsg = bufNew;
}