summaryrefslogtreecommitdiffstats
path: root/tcpsrv.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-12-04 12:11:58 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2008-12-04 12:11:58 +0100
commit2dd15ac57327603307c0ae2f5f96fd1392d6f897 (patch)
treeed15becd6ebc0d6ce3e5ee5d38d7dc211ce5785e /tcpsrv.c
parent56f338f1b4f5f6c428f7aa3fa3f82a13e63e49e7 (diff)
parentd74b4fef35e8a2c3a58fe66720840ae2ee77a02d (diff)
downloadrsyslog-2dd15ac57327603307c0ae2f5f96fd1392d6f897.tar.gz
rsyslog-2dd15ac57327603307c0ae2f5f96fd1392d6f897.tar.xz
rsyslog-2dd15ac57327603307c0ae2f5f96fd1392d6f897.zip
Merge branch 'v3-stable' into beta
Conflicts: ChangeLog configure.ac doc/manual.html
Diffstat (limited to 'tcpsrv.c')
-rw-r--r--tcpsrv.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/tcpsrv.c b/tcpsrv.c
index 17fd58d3..885edba3 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -308,10 +308,10 @@ 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;
+ struct sockaddr_storage *addr;
uchar *fromHostFQDN = NULL;
uchar *fromHostIP = NULL;
@@ -335,13 +335,14 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
/* get the host name */
CHKiRet(netstrm.GetRemoteHName(pNewStrm, &fromHostFQDN));
CHKiRet(netstrm.GetRemoteIP(pNewStrm, &fromHostIP));
+ CHKiRet(netstrm.GetRemAddr(pNewStrm, &addr));
/* TODO: check if we need to strip the domain name here -- rgerhards, 2008-04-24 */
/* Here we check if a host is permitted to send us messages. If it isn't, we do not further
* process the message but log a warning (if we are configured to do this).
* rgerhards, 2005-09-26
*/
- if(!pThis->pIsPermittedHost((struct sockaddr*) &addr, (char*) fromHostFQDN, pThis->pUsr, pSess->pUsr)) {
+ if(!pThis->pIsPermittedHost((struct sockaddr*) addr, (char*) fromHostFQDN, pThis->pUsr, pSess->pUsr)) {
dbgprintf("%s is not an allowed sender\n", fromHostFQDN);
if(glbl.GetOption_DisallowWarning()) {
errno = 0;
@@ -354,7 +355,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));
@@ -367,14 +370,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);
}