summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-03-07 22:29:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:28 -0500
commitaab1dd4ddbe45c625a6e4502cecd20da5762739b (patch)
tree3ec64a202be141866ef1f0c43a9e00c0d66413dd /source3
parent7b2c2e415543aaee13193be1bd11706f2528c692 (diff)
downloadsamba-aab1dd4ddbe45c625a6e4502cecd20da5762739b.tar.gz
samba-aab1dd4ddbe45c625a6e4502cecd20da5762739b.tar.bz2
samba-aab1dd4ddbe45c625a6e4502cecd20da5762739b.zip
r21755: Memory leak fixes from Zack Kirsch <zack.kirsch@isilon.com>.
Jeremy. (This used to be commit 02d08ca0be8c374e30c3c0e665853fa9e57f043a)
Diffstat (limited to 'source3')
-rw-r--r--source3/libads/cldap.c9
-rw-r--r--source3/libsmb/cliconnect.c5
-rw-r--r--source3/torture/nsstest.c6
-rw-r--r--source3/utils/net_rpc.c9
-rw-r--r--source3/utils/pdbedit.c1
5 files changed, 26 insertions, 4 deletions
diff --git a/source3/libads/cldap.c b/source3/libads/cldap.c
index 72018c620d..3cb98c59c5 100644
--- a/source3/libads/cldap.c
+++ b/source3/libads/cldap.c
@@ -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;
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index e2213c1fcd..0f09747dbf 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -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,
diff --git a/source3/torture/nsstest.c b/source3/torture/nsstest.c
index 4b894fbfc3..121679ed8c 100644
--- a/source3/torture/nsstest.c
+++ b/source3/torture/nsstest.c
@@ -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;
}
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index c1d812a8f0..66cb6e6ea6 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -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;
};
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index d79ab187a3..d1a87260fa 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -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());