summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-12-03 11:28:41 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2008-12-03 11:28:41 +0100
commitb41bdeff56ad9d54dddcb8703560c750f04a6370 (patch)
tree01d0c63877678dd96aff9d0270252e40935dddbb
parenta7104880ee05722ad957b32824165561e7085ce8 (diff)
downloadrsyslog-b41bdeff56ad9d54dddcb8703560c750f04a6370.tar.gz
rsyslog-b41bdeff56ad9d54dddcb8703560c750f04a6370.tar.xz
rsyslog-b41bdeff56ad9d54dddcb8703560c750f04a6370.zip
bugfix: memory leak if sender was not permitted
-rw-r--r--tcpsrv.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/tcpsrv.c b/tcpsrv.c
index 1f307b7e..85b34947 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -309,7 +309,7 @@ static rsRetVal
SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
{
DEFiRet;
- tcps_sess_t *pSess;
+ tcps_sess_t *pSess = NULL;
netstrm_t *pNewStrm = NULL;
int iSess = -1;
struct sockaddr_storage *addr;
@@ -356,7 +356,9 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
* means we can finally fill in the session object.
*/
CHKiRet(tcps_sess.SetHost(pSess, fromHostFQDN));
+ fromHostFQDN = NULL; /* we handed this string over */
CHKiRet(tcps_sess.SetHostIP(pSess, fromHostIP));
+ fromHostIP = NULL; /* we handed this string over */
CHKiRet(tcps_sess.SetStrm(pSess, pNewStrm));
pNewStrm = NULL; /* prevent it from being freed in error handler, now done in tcps_sess! */
CHKiRet(tcps_sess.SetMsgIdx(pSess, 0));
@@ -369,14 +371,16 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
*ppSess = pSess;
pThis->pSessions[iSess] = pSess;
+ pSess = NULL; /* this is now also handed over */
finalize_it:
if(iRet != RS_RET_OK) {
- if(iSess != -1) {
- if(pThis->pSessions[iSess] != NULL)
- tcps_sess.Destruct(&pThis->pSessions[iSess]);
- }
- iSess = -1; // TODO: change this to be fully iRet compliant ;)
+ if(pSess != NULL)
+ tcps_sess.Destruct(&pSess);
+ if(fromHostFQDN != NULL)
+ free(fromHostFQDN);
+ if(fromHostIP != NULL)
+ free(fromHostIP);
if(pNewStrm != NULL)
netstrm.Destruct(&pNewStrm);
}