summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/libads/ldap.c3
-rw-r--r--source3/passdb/pdb_ldap.c1
-rw-r--r--source3/utils/net_ads.c11
3 files changed, 13 insertions, 2 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index e9d8bf6bbf..1d08a01a26 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -1635,7 +1635,7 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads, const char *machine_name,
char *samAccountName, *controlstr;
TALLOC_CTX *ctx;
ADS_MODLIST mods;
- char *machine_escaped;
+ char *machine_escaped = NULL;
char *new_dn;
const char *objectClass[] = {"top", "person", "organizationalPerson",
"user", "computer", NULL};
@@ -1681,6 +1681,7 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads, const char *machine_name,
ret = ads_gen_add(ads, new_dn, mods);
done:
+ SAFE_FREE(machine_escaped);
ads_msgfree(ads, res);
talloc_destroy(ctx);
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 4edffe97d9..5fd607a7fc 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -2436,6 +2436,7 @@ static NTSTATUS ldapsam_enum_group_members(struct pdb_methods *methods,
filter = talloc_asprintf_append(filter, "(uid=%s)", escape_memberuid);
if (filter == NULL) {
+ SAFE_FREE(escape_memberuid);
ret = NT_STATUS_NO_MEMORY;
goto done;
}
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index cb5b08c672..b1ac40fd72 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1819,7 +1819,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
TALLOC_CTX *mem_ctx = talloc_init("net_ads_printer_publish");
ADS_MODLIST mods = ads_init_mods(mem_ctx);
char *prt_dn, *srv_dn, **srv_cn;
- char *srv_cn_escaped, *printername_escaped;
+ char *srv_cn_escaped = NULL, *printername_escaped = NULL;
LDAPMessage *res = NULL;
if (!ADS_ERR_OK(ads_startup(True, &ads))) {
@@ -1874,6 +1874,8 @@ static int net_ads_printer_publish(int argc, const char **argv)
srv_cn_escaped = escape_rdn_val_string_alloc(srv_cn[0]);
printername_escaped = escape_rdn_val_string_alloc(printername);
if (!srv_cn_escaped || !printername_escaped) {
+ SAFE_FREE(srv_cn_escaped);
+ SAFE_FREE(printername_escaped);
d_fprintf(stderr, "Internal error, out of memory!");
ads_destroy(&ads);
return -1;
@@ -1881,16 +1883,21 @@ static int net_ads_printer_publish(int argc, const char **argv)
asprintf(&prt_dn, "cn=%s-%s,%s", srv_cn_escaped, printername_escaped, srv_dn);
+ SAFE_FREE(srv_cn_escaped);
+ SAFE_FREE(printername_escaped);
+
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SPOOLSS, &nt_status);
if (!pipe_hnd) {
d_fprintf(stderr, "Unable to open a connnection to the spoolss pipe on %s\n",
servername);
+ SAFE_FREE(prt_dn);
ads_destroy(&ads);
return -1;
}
if (!W_ERROR_IS_OK(get_remote_printer_publishing_data(pipe_hnd, mem_ctx, &mods,
printername))) {
+ SAFE_FREE(prt_dn);
ads_destroy(&ads);
return -1;
}
@@ -1898,11 +1905,13 @@ static int net_ads_printer_publish(int argc, const char **argv)
rc = ads_add_printer_entry(ads, prt_dn, mem_ctx, &mods);
if (!ADS_ERR_OK(rc)) {
d_fprintf(stderr, "ads_publish_printer: %s\n", ads_errstr(rc));
+ SAFE_FREE(prt_dn);
ads_destroy(&ads);
return -1;
}
d_printf("published printer\n");
+ SAFE_FREE(prt_dn);
ads_destroy(&ads);
return 0;