summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2006-06-13 11:37:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:17:23 -0500
commit2828356be330be60cb1cea13ea6460d6f3255696 (patch)
tree490d8cf98f5a90df0b40f7c77971e9e97f2ff15b /source3
parent3ea740f5e5265103eacec2979c6c535eed30e346 (diff)
downloadsamba-2828356be330be60cb1cea13ea6460d6f3255696.tar.gz
samba-2828356be330be60cb1cea13ea6460d6f3255696.tar.bz2
samba-2828356be330be60cb1cea13ea6460d6f3255696.zip
r16187: Fix memleak.
Guenther (This used to be commit e7d2b84aba2f2f5d844ba6a5fdcce35c3750d0b2)
Diffstat (limited to 'source3')
-rw-r--r--source3/nsswitch/winbindd_ads.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/source3/nsswitch/winbindd_ads.c b/source3/nsswitch/winbindd_ads.c
index f777b2ae18..a8eb6f86d0 100644
--- a/source3/nsswitch/winbindd_ads.c
+++ b/source3/nsswitch/winbindd_ads.c
@@ -723,7 +723,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
ADS_STATUS rc;
int count;
LDAPMessage *msg = NULL;
- char *user_dn;
+ char *user_dn = NULL;
DOM_SID *sids;
int i;
DOM_SID primary_group;
@@ -791,9 +791,6 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
count = ads_pull_sids(ads, mem_ctx, msg, "tokenGroups", &sids);
- if (msg)
- ads_msgfree(ads, msg);
-
/* there must always be at least one group in the token,
unless we are talking to a buggy Win2k server */
@@ -811,15 +808,16 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
&primary_group,
p_num_groups, user_sids);
if (NT_STATUS_IS_OK(status)) {
- return status;
+ goto done;
}
/* lookup what groups this user is a member of by DN search on
* "member" */
- return lookup_usergroups_member(domain, mem_ctx, user_dn,
- &primary_group,
- p_num_groups, user_sids);
+ status = lookup_usergroups_member(domain, mem_ctx, user_dn,
+ &primary_group,
+ p_num_groups, user_sids);
+ goto done;
}
*user_sids = NULL;
@@ -844,6 +842,8 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
DEBUG(3,("ads lookup_usergroups (tokenGroups) succeeded for sid=%s\n",
sid_to_string(sid_string, sid)));
done:
+ ads_memfree(ads, user_dn);
+ ads_msgfree(ads, msg);
return status;
}
@@ -885,7 +885,10 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
goto done;
}
- sidstr = sid_binstring(group_sid);
+ if ((sidstr = sid_binstring(group_sid)) == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
/* search for all members of the group */
if (!(ldap_exp = talloc_asprintf(mem_ctx, "(objectSid=%s)",sidstr))) {