Thursday, March 26, 2020

[389-commits] [389-ds-base] branch 389-ds-base-1.4.1 updated: Issue 49437 - Fix memory leak with indirect COS

This is an automated email from the git hooks/post-receive script.

mreynolds pushed a commit to branch 389-ds-base-1.4.1
in repository 389-ds-base.

The following commit(s) were added to refs/heads/389-ds-base-1.4.1 by this push:
new 4a1251e Issue 49437 - Fix memory leak with indirect COS
4a1251e is described below

commit 4a1251e4b7d7765b57f45b14da47604c0ba1d271
Author: Mark Reynolds <mreynolds@redhat.com>
AuthorDate: Wed Mar 25 16:55:34 2020 -0400

Issue 49437 - Fix memory leak with indirect COS

Bug Description: There are two leaks when dealing with indirect COS. The
first leak is caused by the COS cache entry's objectclass
list not being freed when the entry is removed from the
hash table.

The other leak is caused when we follow an indirect pointer
COS and do not free a tmp value set that goes unused.

Fix description: Free the COS entry objectclass list when removing an entry
from the hash table. When querying a COS attribute and the
returned attribute (out_attr) is NULL, then free the unused
tmp_val ValueSet as it's not consumed by anything.

Fixes: https://pagure.io/389-ds-base/issue/49437

Reviewed by: firstyear & tbordaz(Thanks!)
---
ldap/servers/plugins/cos/cos_cache.c | 3 +++
ldap/servers/slapd/vattr.c | 39 +++++++++++++++++++-----------------
2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/ldap/servers/plugins/cos/cos_cache.c b/ldap/servers/plugins/cos/cos_cache.c
index 64c0441..eb9bd77 100644
--- a/ldap/servers/plugins/cos/cos_cache.c
+++ b/ldap/servers/plugins/cos/cos_cache.c
@@ -2372,6 +2372,9 @@ cos_cache_query_attr(cos_cache *ptheCache, vattr_context *context, Slapi_Entry *
*out_attr = tmp_vals;
tmp_vals = NULL;
}
+ } else if (out_attr == NULL && tmp_vals) {
+ slapi_valueset_free(tmp_vals);
+ tmp_vals = NULL;
}
}

diff --git a/ldap/servers/slapd/vattr.c b/ldap/servers/slapd/vattr.c
index 852a887..d8b2c83 100644
--- a/ldap/servers/slapd/vattr.c
+++ b/ldap/servers/slapd/vattr.c
@@ -2004,6 +2004,24 @@ vattr_map_create(void)
return 0;
}

+/*
+ vattr_delete_attrvals
+ ---------------------
+ deletes a value list
+*/
+void
+vattr_delete_attrvals(objAttrValue **attrval)
+{
+ objAttrValue *val = *attrval;
+
+ while (val) {
+ objAttrValue *next = val->pNext;
+ slapi_value_free(&val->val);
+ slapi_ch_free((void **)&val);
+ val = next;
+ }
+}
+
void
vattr_map_entry_free(vattr_map_entry *vae)
{
@@ -2016,6 +2034,9 @@ vattr_map_entry_free(vattr_map_entry *vae)
}
list_entry = next_entry;
}
+ if (vae->objectclasses) {
+ vattr_delete_attrvals(&(vae->objectclasses));
+ }
slapi_ch_free_string(&(vae->type_name));
slapi_ch_free((void **)&vae);
}
@@ -2103,24 +2124,6 @@ vattr_map_insert(vattr_map_entry *vae)
}

/*
- vattr_delete_attrvals
- ---------------------
- deletes a value list
-*/
-void
-vattr_delete_attrvals(objAttrValue **attrval)
-{
- objAttrValue *val = *attrval;
-
- while (val) {
- objAttrValue *next = val->pNext;
- slapi_value_free(&val->val);
- slapi_ch_free((void **)&val);
- val = next;
- }
-}
-
-/*
vattr_add_attrval
-----------------
adds a value to an attribute value list

--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
389-commits mailing list -- 389-commits@lists.fedoraproject.org
To unsubscribe send an email to 389-commits-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/389-commits@lists.fedoraproject.org

No comments:

Post a Comment