r21755: Memory leak fixes from Zack Kirsch <zack.kirsch@isilon.com>.
authorJeremy Allison <jra@samba.org>
Wed, 7 Mar 2007 22:29:21 +0000 (22:29 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:18:28 +0000 (12:18 -0500)
Jeremy.
(This used to be commit 02d08ca0be8c374e30c3c0e665853fa9e57f043a)

source3/libads/cldap.c
source3/libsmb/cliconnect.c
source3/torture/nsstest.c
source3/utils/net_rpc.c
source3/utils/pdbedit.c

index 72018c620d8ac43dd74be52983fba91cbfdc32e9..3cb98c59c58ff801e737610fc511567fde8c04dc 100644 (file)
@@ -187,8 +187,10 @@ static int recv_cldap_netlogon(int sock, struct cldap_netlogon_reply *reply)
 {
        int ret;
        ASN1_DATA data;
-       DATA_BLOB blob;
-       DATA_BLOB os1, os2, os3;
+       DATA_BLOB blob = data_blob(NULL, 0);
+       DATA_BLOB os1 = data_blob(NULL, 0);
+       DATA_BLOB os2 = data_blob(NULL, 0);
+       DATA_BLOB os3 = data_blob(NULL, 0);
        int i1;
        /* half the time of a regular ldap timeout, not less than 3 seconds. */
        unsigned int al_secs = MAX(3,lp_ldap_timeout()/2);
@@ -238,6 +240,9 @@ static int recv_cldap_netlogon(int sock, struct cldap_netlogon_reply *reply)
 
        if (data.has_error) {
                data_blob_free(&blob);
+               data_blob_free(&os1);
+               data_blob_free(&os2);
+               data_blob_free(&os3);
                asn1_free(&data);
                DEBUG(1,("Failed to parse cldap reply\n"));
                return -1;
index e2213c1fcde11aa4d3142846a77ff054522120eb..0f09747dbf1115d1a2ba82e94132a20f32b8b037 100644 (file)
@@ -693,8 +693,6 @@ static NTSTATUS cli_session_setup_ntlmssp(struct cli_state *cli, const char *use
                                DEBUG(3, ("Failed to send NTLMSSP/SPNEGO blob to server!\n"));
                                nt_status = NT_STATUS_UNSUCCESSFUL;
                        } else {
-                               data_blob_free(&msg1);
-                               
                                blob = cli_session_setup_blob_receive(cli);
                                
                                nt_status = cli_nt_error(cli);
@@ -706,6 +704,7 @@ static NTSTATUS cli_session_setup_ntlmssp(struct cli_state *cli, const char *use
                                        }
                                }
                        }
+                       data_blob_free(&msg1);
                }
                
                if (!blob.length) {
@@ -736,6 +735,8 @@ static NTSTATUS cli_session_setup_ntlmssp(struct cli_state *cli, const char *use
                turn++;
        } while (NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED));
 
+       data_blob_free(&blob_in);
+
        if (NT_STATUS_IS_OK(nt_status)) {
 
                DATA_BLOB key = data_blob(ntlmssp_state->session_key.data,
index 4b894fbfc34bdf346006d9959e876628036676e3..121679ed8cc44b70620fb30651a89d8a6e49ada9 100644 (file)
@@ -229,12 +229,15 @@ again:
                goto again;
        }
        if (status == NSS_STATUS_NOTFOUND) {
+               SAFE_FREE(buf);
                return NULL;
        }
        if (status != NSS_STATUS_SUCCESS) {
                report_nss_error("getgrnam", status);
+               SAFE_FREE(buf);
                return NULL;
        }
+       SAFE_FREE(buf);
        return &grp;
 }
 
@@ -266,12 +269,15 @@ again:
                goto again;
        }
        if (status == NSS_STATUS_NOTFOUND) {
+               SAFE_FREE(buf);
                return NULL;
        }
        if (status != NSS_STATUS_SUCCESS) {
                report_nss_error("getgrgid", status);
+               SAFE_FREE(buf);
                return NULL;
        }
+       SAFE_FREE(buf);
        return &grp;
 }
 
index c1d812a8f0bdab6e8d5f9a3b603b0fa14232765d..66cb6e6ea6c7fbdb37cc7aa1090d2c7c9b9fc1e2 100644 (file)
@@ -5963,6 +5963,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
        if (!pipe_hnd) {
                DEBUG(0, ("Could not initialise lsa pipe. Error was %s\n",
                        nt_errstr(nt_status) ));
+               cli_shutdown(cli);
                talloc_destroy(mem_ctx);
                return -1;
        };
@@ -5972,6 +5973,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
        if (NT_STATUS_IS_ERR(nt_status)) {
                DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
                        nt_errstr(nt_status)));
+               cli_shutdown(cli);
                talloc_destroy(mem_ctx);
                return -1;
        };
@@ -5984,6 +5986,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
        if (NT_STATUS_IS_ERR(nt_status)) {
                DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
                        nt_errstr(nt_status)));
+               cli_shutdown(cli);
                talloc_destroy(mem_ctx);
                return -1;
        }
@@ -6003,6 +6006,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
                if (NT_STATUS_IS_ERR(nt_status)) {
                        DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
                                nt_errstr(nt_status)));
+                       cli_shutdown(cli);
                        talloc_destroy(mem_ctx);
                        return -1;
                };
@@ -6024,6 +6028,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
        if (NT_STATUS_IS_ERR(nt_status)) {
                DEBUG(0, ("Couldn't properly close lsa policy handle. Error was %s\n",
                        nt_errstr(nt_status)));
+               cli_shutdown(cli);
                talloc_destroy(mem_ctx);
                return -1;
        };
@@ -6042,6 +6047,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
        pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &nt_status);
        if (!pipe_hnd) {
                DEBUG(0, ("Could not initialise samr pipe. Error was %s\n", nt_errstr(nt_status)));
+               cli_shutdown(cli);
                talloc_destroy(mem_ctx);
                return -1;
        };
@@ -6052,6 +6058,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("Couldn't open SAMR policy handle. Error was %s\n",
                        nt_errstr(nt_status)));
+               cli_shutdown(cli);
                talloc_destroy(mem_ctx);
                return -1;
        };
@@ -6064,6 +6071,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("Couldn't open domain object. Error was %s\n",
                        nt_errstr(nt_status)));
+               cli_shutdown(cli);
                talloc_destroy(mem_ctx);
                return -1;
        };
@@ -6082,6 +6090,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
                if (NT_STATUS_IS_ERR(nt_status)) {
                        DEBUG(0, ("Couldn't enumerate accounts. Error was: %s\n",
                                nt_errstr(nt_status)));
+                       cli_shutdown(cli);
                        talloc_destroy(mem_ctx);
                        return -1;
                };
index d79ab187a3b6aff677704de616446857559251eb..d1a87260fa90003cd9228073c76eab0eec7e78e3 100644 (file)
@@ -573,6 +573,7 @@ static int new_user (struct pdb_methods *in, const char *username,
                        
                        if (sscanf(user_sid, "%d", &u_rid) != 1) {
                                fprintf(stderr, "Error passed string is not a complete user SID or RID!\n");
+                               TALLOC_FREE(sam_pwent);
                                return -1;
                        }
                        sid_copy(&u_sid, get_global_sam_sid());