summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--plugins/imtcp/imtcp.c1
-rw-r--r--tools/omfwd.c28
3 files changed, 23 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c2d6312a..0c7a4109 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ Version 3.19.6 (rgerhards), 2008-06-??
- bugfix: part of permittedPeer structure was not correctly initialized
thanks to varmojfekoj for spotting this
- bugfix: off-by-one bug during certificate check
+- bugfix: removed some memory leaks in TLS code
---------------------------------------------------------------------------
Version 3.19.5 (rgerhards), 2008-05-30
- enabled Posix ERE expressions inside the property replacer
diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c
index d8363151..d50d80e9 100644
--- a/plugins/imtcp/imtcp.c
+++ b/plugins/imtcp/imtcp.c
@@ -147,6 +147,7 @@ setPermittedPeer(void __attribute__((unused)) *pVal, uchar *pszID)
{
DEFiRet;
CHKiRet(net.AddPermittedPeer(&pPermPeersRoot, pszID));
+ free(pszID); /* no longer needed, but we need to free as of interface def */
finalize_it:
RETiRet;
}
diff --git a/tools/omfwd.c b/tools/omfwd.c
index f8ed81dc..317bc298 100644
--- a/tools/omfwd.c
+++ b/tools/omfwd.c
@@ -117,6 +117,22 @@ static char *getFwdPt(instanceData *pData)
return(pData->port);
}
+
+/* destruct the TCP helper objects
+ * This, for example, is needed after something went wrong.
+ * This function is void because it "can not" fail.
+ * rgerhards, 2008-06-04
+ */
+static inline void
+DestructTCPInstanceData(instanceData *pData)
+{
+ assert(pData != NULL);
+ if(pData->pNetstrm != NULL)
+ netstrm.Destruct(&pData->pNetstrm);
+ if(pData->pNS != NULL)
+ netstrms.Destruct(&pData->pNS);
+}
+
BEGINcreateInstance
CODESTARTcreateInstance
ENDcreateInstance
@@ -139,8 +155,7 @@ CODESTARTfreeInstance
free(pData->port);
/* final cleanup */
- if(pData->pNetstrm != NULL)
- netstrm.Destruct(&pData->pNetstrm);
+ DestructTCPInstanceData(pData);
if(pData->pSockArray != NULL)
net.closeUDPListenSockets(pData->pSockArray);
@@ -219,6 +234,7 @@ setPermittedPeer(void __attribute__((unused)) *pVal, uchar *pszID)
{
DEFiRet;
CHKiRet(net.AddPermittedPeer(&pPermPeers, pszID));
+ free(pszID); /* no longer needed, but we must free it as of interface def */
finalize_it:
RETiRet;
}
@@ -266,7 +282,7 @@ static rsRetVal TCPSendPrepRetry(void *pvData)
instanceData *pData = (instanceData *) pvData;
assert(pData != NULL);
- netstrm.Destruct(&pData->pNetstrm);
+ DestructTCPInstanceData(pData);
RETiRet;
}
@@ -304,10 +320,7 @@ static rsRetVal TCPSendInit(void *pvData)
finalize_it:
if(iRet != RS_RET_OK) {
- if(pData->pNetstrm != NULL)
- netstrm.Destruct(&pData->pNetstrm);
- if(pData->pNS != NULL)
- netstrms.Destruct(&pData->pNS);
+ DestructTCPInstanceData(pData);
}
RETiRet;
@@ -426,6 +439,7 @@ CODESTARTdoAction
if(ret != RS_RET_OK) {
/* error! */
dbgprintf("error forwarding via tcp, suspending\n");
+ DestructTCPInstanceData(pData);
iRet = RS_RET_SUSPENDED;
}
}