1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

r18923: Fix more memleaks.

Guenther
(This used to be commit ecb632a153)
This commit is contained in:
Günther Deschner 2006-09-26 16:27:18 +00:00 committed by Gerald (Jerry) Carter
parent bf6962b5e8
commit f7633eca18
3 changed files with 23 additions and 7 deletions

View File

@ -276,6 +276,7 @@ ADS_STATUS ads_add_gpo_link(ADS_STRUCT *ads,
if (ads_count_replies(ads, res) != 1) {
DEBUG(10,("ads_add_gpo_link: no result\n"));
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
}
@ -286,6 +287,7 @@ ADS_STATUS ads_add_gpo_link(ADS_STRUCT *ads,
gp_link_new = talloc_asprintf(mem_ctx, "%s[%s;%d]", gp_link, gpo_dn, gpo_opt);
}
ads_msgfree(ads, res);
if (gp_link_new == NULL) {
return ADS_ERROR(LDAP_NO_MEMORY);
}
@ -334,6 +336,7 @@ ADS_STATUS ads_delete_gpo_link(ADS_STRUCT *ads,
if (ads_count_replies(ads, res) != 1) {
DEBUG(10,("ads_delete_gpo_link: no result\n"));
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
}
@ -343,8 +346,9 @@ ADS_STATUS ads_delete_gpo_link(ADS_STRUCT *ads,
}
/* find link to delete */
// gp_link_new = talloc_asprintf(mem_ctx, "%s[%s;%d]", gp_link, gpo_dn, gpo_opt);
/* gp_link_new = talloc_asprintf(mem_ctx, "%s[%s;%d]", gp_link, gpo_dn, gpo_opt); */
ads_msgfree(ads, res);
if (gp_link_new == NULL) {
return ADS_ERROR(LDAP_NO_MEMORY);
}

View File

@ -465,8 +465,6 @@ ADS_STATUS gpo_password_policy(ADS_STRUCT *ads,
LDAPMessage *res = NULL;
uint32 uac;
return ADS_ERROR_NT(NT_STATUS_NOT_IMPLEMENTED);
filter = talloc_asprintf(mem_ctx, "(&(objectclass=user)(sAMAccountName=%s))", hostname);
if (filter == NULL) {
return ADS_ERROR(LDAP_NO_MEMORY);
@ -481,19 +479,24 @@ ADS_STATUS gpo_password_policy(ADS_STRUCT *ads,
}
if (ads_count_replies(ads, res) != 1) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
}
dn = ads_get_dn(ads, res);
if (dn == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY);
}
if (!ads_pull_uint32(ads, res, "userAccountControl", &uac)) {
ads_msgfree(ads, res);
ads_memfree(ads, dn);
return ADS_ERROR(LDAP_NO_MEMORY);
}
ads_msgfree(ads, res);
if (!(uac & UF_WORKSTATION_TRUST_ACCOUNT)) {
ads_memfree(ads, dn);
return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
@ -505,15 +508,15 @@ ADS_STATUS gpo_password_policy(ADS_STRUCT *ads,
return status;
}
ads_memfree(ads, dn);
status = gpo_process_gpo_list(ads, mem_ctx, &gpo_list,
cse_gpo_name_to_guid_string("Security"),
GPO_LIST_FLAG_MACHINE);
if (!ADS_ERR_OK(status)) {
ads_memfree(ads, dn);
return status;
}
ads_memfree(ads, dn);
return ADS_ERROR(LDAP_SUCCESS);
}

View File

@ -2458,9 +2458,12 @@ ADS_STATUS ads_site_dn(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char **site_n
service_name = ads_pull_string(ads, mem_ctx, res, "dsServiceName");
if (service_name == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_RESULTS_RETURNED);
}
ads_msgfree(ads, res);
/* go up three levels */
dn = ads_parent_dn(ads_parent_dn(ads_parent_dn(service_name)));
if (dn == NULL) {
@ -2472,8 +2475,6 @@ ADS_STATUS ads_site_dn(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char **site_n
return ADS_ERROR(LDAP_NO_MEMORY);
}
ads_msgfree(ads, res);
return status;
/*
dsServiceName: CN=NTDS Settings,CN=W2K3DC,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=ber,DC=suse,DC=de
@ -2508,37 +2509,45 @@ ADS_STATUS ads_site_dn_for_machine(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const c
config_context = ads_pull_string(ads, mem_ctx, res, "configurationNamingContext");
if (config_context == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY);
}
filter = talloc_asprintf(mem_ctx, "(cn=%s)", computer_name);
if (filter == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY);
}
ads_msgfree(ads, res);
status = ads_do_search(ads, config_context, LDAP_SCOPE_SUBTREE, filter, NULL, &res);
if (!ADS_ERR_OK(status)) {
return status;
}
if (ads_count_replies(ads, res) != 1) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
}
dn = ads_get_dn(ads, res);
if (dn == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY);
}
/* go up three levels */
parent = ads_parent_dn(ads_parent_dn(ads_parent_dn(dn)));
if (parent == NULL) {
ads_msgfree(ads, res);
ads_memfree(ads, dn);
return ADS_ERROR(LDAP_NO_MEMORY);
}
*site_dn = talloc_strdup(mem_ctx, parent);
if (*site_dn == NULL) {
ads_msgfree(ads, res);
ads_memfree(ads, dn);
ADS_ERROR(LDAP_NO_MEMORY);
}