From bbc86bba2bf5edd75551104ffe7186a5fe3d6a7c Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Mon, 17 Nov 2014 09:46:33 -0500
Subject: [PATCH 274/305] Ticket 47958 - Memory leak in password admin if the
admin entry does not exist
Bug Description: If passwordAdminDN is set to an entry that does not exist memory
is leaked.
Fix Description: The leak occurs because we do not free the internal search results,
even when zero entries are returned.
https://fedorahosted.org/389/ticket/47958
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit 6ee9a1bd3aa5014aff3b8b07a032c35a1c66d2e2)
Conflicts:
ldap/servers/slapd/pw.c
(cherry picked from commit d9274e23f8132c2624413915d3e2e040d48bf152)
---
ldap/servers/slapd/pw.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index d32afd8..e0d0080 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -1573,20 +1573,25 @@ pw_get_admin_users(passwdPolicy *pwp)
if(binddn == NULL){
return;
}
- pb = slapi_pblock_new();
+
/*
* Check if the DN exists and has "group" objectclasses
*/
- slapi_search_internal_set_pb(pb, binddn, LDAP_SCOPE_BASE,"(|(objectclass=groupofuniquenames)(objectclass=groupofnames))",
- NULL, 0, NULL, NULL, (void *) plugin_get_default_component_id(), 0);
+ pb = slapi_pblock_new();
+ slapi_search_internal_set_pb(pb, binddn, LDAP_SCOPE_BASE,
+ "(|(objectclass=groupofuniquenames)(objectclass=groupofnames))",
+ NULL, 0, NULL, NULL, (void *) plugin_get_default_component_id(), 0);
slapi_search_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
if (res != LDAP_SUCCESS) {
+ slapi_free_search_results_internal(pb);
slapi_pblock_destroy(pb);
- LDAPDebug(LDAP_DEBUG_ANY, "pw_get_admin_users: search failed for %s: error %d - Password Policy Administrators can not be set\n",
- slapi_sdn_get_dn(sdn), res, 0);
+ LDAPDebug(LDAP_DEBUG_ANY, "pw_get_admin_users: search failed for %s: error %d - "
+ "Password Policy Administrators can not be set\n",
+ slapi_sdn_get_dn(sdn), res, 0);
return;
}
+
/*
* Ok, we know we have a valid DN, and nentries will tell us if its a group or a user
*/
@@ -1600,7 +1605,8 @@ pw_get_admin_users(passwdPolicy *pwp)
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
uniquemember_vals = slapi_entry_attr_get_charray_ext(entries[0], "uniquemember", &uniquemember_count);
member_vals = slapi_entry_attr_get_charray_ext(entries[0], "member", &member_count);
- pwp->pw_admin_user = (Slapi_DN **)slapi_ch_calloc((uniquemember_count + member_count + 1), sizeof(Slapi_DN *));
+ pwp->pw_admin_user = (Slapi_DN **)slapi_ch_calloc((uniquemember_count + member_count + 1),
+ sizeof(Slapi_DN *));
if(uniquemember_count > 0){
for(i = 0; i < uniquemember_count; i++){
pwp->pw_admin_user[count++] = slapi_sdn_new_dn_passin(uniquemember_vals[i]);
--
1.9.3