]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix memory leaks in NTLM session helper RFCNB_Call(...)
authoramosjeffries <>
Fri, 3 Aug 2007 07:21:17 +0000 (07:21 +0000)
committeramosjeffries <>
Fri, 3 Aug 2007 07:21:17 +0000 (07:21 +0000)
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.

helpers/ntlm_auth/SMB/smbval/session.c

index cf6131e81925306648b8d793a4576d8a73e86049..9c527b4b365d0e88809c57cf738c560baf37701b 100644 (file)
@@ -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);
 
        }