summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-03-01 02:43:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:16 -0500
commit8e00e9d7a6114089fc176bc3446c6c97a01543d6 (patch)
tree9c5b58be176c12282be1226dd4369cb80a66bb6b /source3/utils
parentfae01b48994fd3168fd921af68dab1b4003adc49 (diff)
downloadsamba-8e00e9d7a6114089fc176bc3446c6c97a01543d6.tar.gz
samba-8e00e9d7a6114089fc176bc3446c6c97a01543d6.tar.bz2
samba-8e00e9d7a6114089fc176bc3446c6c97a01543d6.zip
r21609: Fix memory leaks in error code paths (and one in winbindd_group.c).
Patch from Zack Kirsch <zack.kirsch@isilon.com>. Jeremy. (This used to be commit df07a662e32367a52c1e8473475423db2ff5bc51)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_ads.c9
-rw-r--r--source3/utils/net_rpc.c22
2 files changed, 31 insertions, 0 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index b1ac40fd72..363bfbc666 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1823,10 +1823,12 @@ static int net_ads_printer_publish(int argc, const char **argv)
LDAPMessage *res = NULL;
if (!ADS_ERR_OK(ads_startup(True, &ads))) {
+ talloc_destroy(mem_ctx);
return -1;
}
if (argc < 1) {
+ talloc_destroy(mem_ctx);
return net_ads_printer_usage(argc, argv);
}
@@ -1854,6 +1856,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
d_fprintf(stderr, "Unable to open a connnection to %s to obtain data "
"for %s\n", servername, printername);
ads_destroy(&ads);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -1865,6 +1868,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
d_fprintf(stderr, "Could not find machine account for server %s\n",
servername);
ads_destroy(&ads);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -1878,6 +1882,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
SAFE_FREE(printername_escaped);
d_fprintf(stderr, "Internal error, out of memory!");
ads_destroy(&ads);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -1892,6 +1897,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
servername);
SAFE_FREE(prt_dn);
ads_destroy(&ads);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -1899,6 +1905,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
printername))) {
SAFE_FREE(prt_dn);
ads_destroy(&ads);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -1907,12 +1914,14 @@ static int net_ads_printer_publish(int argc, const char **argv)
d_fprintf(stderr, "ads_publish_printer: %s\n", ads_errstr(rc));
SAFE_FREE(prt_dn);
ads_destroy(&ads);
+ talloc_destroy(mem_ctx);
return -1;
}
d_printf("published printer\n");
SAFE_FREE(prt_dn);
ads_destroy(&ads);
+ talloc_destroy(mem_ctx);
return 0;
}
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 94708ad2cc..c1d812a8f0 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -5574,6 +5574,7 @@ static int rpc_trustdom_establish(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;
}
@@ -5583,6 +5584,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
nt_errstr(nt_status)));
cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -5595,6 +5597,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
nt_errstr(nt_status)));
cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -5608,6 +5611,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
if (!pdb_set_trusteddom_pw(domain_name, opt_password, domain_sid)) {
DEBUG(0, ("Storing password for trusted domain failed.\n"));
cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -5620,6 +5624,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
DEBUG(0, ("Couldn't close LSA pipe. Error was %s\n",
nt_errstr(nt_status)));
cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -5807,6 +5812,7 @@ static int rpc_trustdom_vampire(int argc, const char **argv)
/* open \PIPE\lsarpc and open policy handle */
if (!(cli = net_make_ipc_connection(NET_FLAGS_PDC))) {
DEBUG(0, ("Couldn't connect to domain controller\n"));
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -5815,6 +5821,7 @@ static int rpc_trustdom_vampire(int argc, const char **argv)
DEBUG(0, ("Could not initialise lsa pipe. Error was %s\n",
nt_errstr(nt_status) ));
cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -5824,6 +5831,7 @@ static int rpc_trustdom_vampire(int argc, const char **argv)
DEBUG(0, ("Couldn't open policy handle. Error was %s\n",
nt_errstr(nt_status)));
cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -5836,6 +5844,7 @@ static int rpc_trustdom_vampire(int argc, const char **argv)
DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
nt_errstr(nt_status)));
cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -5855,6 +5864,7 @@ static int rpc_trustdom_vampire(int argc, const char **argv)
DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
nt_errstr(nt_status)));
cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -5866,6 +5876,7 @@ static int rpc_trustdom_vampire(int argc, const char **argv)
domain_sids[i], trusted_dom_names[i]);
if (!NT_STATUS_IS_OK(nt_status)) {
cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
return -1;
}
};
@@ -5884,6 +5895,7 @@ static int rpc_trustdom_vampire(int argc, const char **argv)
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;
};
@@ -5943,6 +5955,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
/* open \PIPE\lsarpc and open policy handle */
if (!(cli = net_make_ipc_connection(NET_FLAGS_PDC))) {
DEBUG(0, ("Couldn't connect to domain controller\n"));
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -5950,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) ));
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -5958,6 +5972,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)));
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -5969,6 +5984,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)));
+ talloc_destroy(mem_ctx);
return -1;
}
@@ -5987,6 +6003,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)));
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -6007,6 +6024,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)));
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -6024,6 +6042,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)));
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -6033,6 +6052,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)));
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -6044,6 +6064,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)));
+ talloc_destroy(mem_ctx);
return -1;
};
@@ -6061,6 +6082,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)));
+ talloc_destroy(mem_ctx);
return -1;
};