From: amosjeffries <> Date: Fri, 3 Aug 2007 07:21:17 +0000 (+0000) Subject: Fix memory leaks in NTLM session helper RFCNB_Call(...) X-Git-Tag: SQUID_3_0_PRE7~116 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9dff964b27006407e53049a61cd2d22d397755c;p=thirdparty%2Fsquid.git Fix memory leaks in NTLM session helper RFCNB_Call(...) Coverity checker identified that the connect structures were not being free'd on any of the error cases. This patch adds several calls to free(con) to prevent the leaks. It also adds a call to close any partial connections properly when RFCNB_Session_Req fails. Previously it would leave the open TCP connection hanging and return a NULL pointer. --- diff --git a/helpers/ntlm_auth/SMB/smbval/session.c b/helpers/ntlm_auth/SMB/smbval/session.c index cf6131e819..9c527b4b36 100644 --- a/helpers/ntlm_auth/SMB/smbval/session.c +++ b/helpers/ntlm_auth/SMB/smbval/session.c @@ -112,7 +112,7 @@ RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, if ((errno = RFCNB_Name_To_IP(Service_Address, &Dest_IP)) < 0) { /* Error */ /* No need to modify RFCNB_errno as it was done by RFCNB_Name_To_IP */ - + free(con); return (NULL); } @@ -131,6 +131,7 @@ RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, RFCNB_errno = RFCNBE_NoSpace; RFCNB_saved_errno = errno; + free(con); return (NULL); } @@ -154,7 +155,7 @@ RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, if ((Client = RFCNB_IP_Connect(Dest_IP, port)) < 0) { /* Error */ /* No need to modify RFCNB_errno as it was done by RFCNB_IP_Connect */ - + free(con); return (NULL); } @@ -170,7 +171,8 @@ RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, &redirect, &Dest_IP, &port)) < 0) { /* No need to modify RFCNB_errno as it was done by RFCNB_Session.. */ - + RFCNB_Close(con->fd); /* Close it */ + free(con); return (NULL); }