|
|
de47d7 |
From 3a8d5bc4dce01fb800c93434181060afe9287546 Mon Sep 17 00:00:00 2001
|
|
|
de47d7 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
de47d7 |
Date: Wed, 25 Mar 2020 16:55:34 -0400
|
|
|
de47d7 |
Subject: [PATCH 2/4] Issue 49437 - Fix memory leak with indirect COS
|
|
|
de47d7 |
|
|
|
de47d7 |
Bug Description: There are two leaks when dealing with indirect COS. The
|
|
|
de47d7 |
first leak is caused by the COS cache entry's objectclass
|
|
|
de47d7 |
list not being freed when the entry is removed from the
|
|
|
de47d7 |
hash table.
|
|
|
de47d7 |
|
|
|
de47d7 |
The other leak is caused when we follow an indirect pointer
|
|
|
de47d7 |
COS and do not free a tmp value set that goes unused.
|
|
|
de47d7 |
|
|
|
de47d7 |
Fix description: Free the COS entry objectclass list when removing an entry
|
|
|
de47d7 |
from the hash table. When querying a COS attribute and the
|
|
|
de47d7 |
returned attribute (out_attr) is NULL, then free the unused
|
|
|
de47d7 |
tmp_val ValueSet as it's not consumed by anything.
|
|
|
de47d7 |
|
|
|
de47d7 |
Fixes: https://pagure.io/389-ds-base/issue/49437
|
|
|
de47d7 |
|
|
|
de47d7 |
Reviewed by: firstyear & tbordaz(Thanks!)
|
|
|
de47d7 |
---
|
|
|
de47d7 |
ldap/servers/plugins/cos/cos_cache.c | 3 +++
|
|
|
de47d7 |
ldap/servers/slapd/vattr.c | 39 +++++++++++++++-------------
|
|
|
de47d7 |
2 files changed, 24 insertions(+), 18 deletions(-)
|
|
|
de47d7 |
|
|
|
de47d7 |
diff --git a/ldap/servers/plugins/cos/cos_cache.c b/ldap/servers/plugins/cos/cos_cache.c
|
|
|
de47d7 |
index 64c0441c4..eb9bd77f9 100644
|
|
|
de47d7 |
--- a/ldap/servers/plugins/cos/cos_cache.c
|
|
|
de47d7 |
+++ b/ldap/servers/plugins/cos/cos_cache.c
|
|
|
de47d7 |
@@ -2372,6 +2372,9 @@ cos_cache_query_attr(cos_cache *ptheCache, vattr_context *context, Slapi_Entry *
|
|
|
de47d7 |
*out_attr = tmp_vals;
|
|
|
de47d7 |
tmp_vals = NULL;
|
|
|
de47d7 |
}
|
|
|
de47d7 |
+ } else if (out_attr == NULL && tmp_vals) {
|
|
|
de47d7 |
+ slapi_valueset_free(tmp_vals);
|
|
|
de47d7 |
+ tmp_vals = NULL;
|
|
|
de47d7 |
}
|
|
|
de47d7 |
}
|
|
|
de47d7 |
|
|
|
de47d7 |
diff --git a/ldap/servers/slapd/vattr.c b/ldap/servers/slapd/vattr.c
|
|
|
de47d7 |
index 852a887ce..d8b2c835a 100644
|
|
|
de47d7 |
--- a/ldap/servers/slapd/vattr.c
|
|
|
de47d7 |
+++ b/ldap/servers/slapd/vattr.c
|
|
|
de47d7 |
@@ -2004,6 +2004,24 @@ vattr_map_create(void)
|
|
|
de47d7 |
return 0;
|
|
|
de47d7 |
}
|
|
|
de47d7 |
|
|
|
de47d7 |
+/*
|
|
|
de47d7 |
+ vattr_delete_attrvals
|
|
|
de47d7 |
+ ---------------------
|
|
|
de47d7 |
+ deletes a value list
|
|
|
de47d7 |
+*/
|
|
|
de47d7 |
+void
|
|
|
de47d7 |
+vattr_delete_attrvals(objAttrValue **attrval)
|
|
|
de47d7 |
+{
|
|
|
de47d7 |
+ objAttrValue *val = *attrval;
|
|
|
de47d7 |
+
|
|
|
de47d7 |
+ while (val) {
|
|
|
de47d7 |
+ objAttrValue *next = val->pNext;
|
|
|
de47d7 |
+ slapi_value_free(&val->val);
|
|
|
de47d7 |
+ slapi_ch_free((void **)&val;;
|
|
|
de47d7 |
+ val = next;
|
|
|
de47d7 |
+ }
|
|
|
de47d7 |
+}
|
|
|
de47d7 |
+
|
|
|
de47d7 |
void
|
|
|
de47d7 |
vattr_map_entry_free(vattr_map_entry *vae)
|
|
|
de47d7 |
{
|
|
|
de47d7 |
@@ -2016,6 +2034,9 @@ vattr_map_entry_free(vattr_map_entry *vae)
|
|
|
de47d7 |
}
|
|
|
de47d7 |
list_entry = next_entry;
|
|
|
de47d7 |
}
|
|
|
de47d7 |
+ if (vae->objectclasses) {
|
|
|
de47d7 |
+ vattr_delete_attrvals(&(vae->objectclasses));
|
|
|
de47d7 |
+ }
|
|
|
de47d7 |
slapi_ch_free_string(&(vae->type_name));
|
|
|
de47d7 |
slapi_ch_free((void **)&vae;;
|
|
|
de47d7 |
}
|
|
|
de47d7 |
@@ -2102,24 +2123,6 @@ vattr_map_insert(vattr_map_entry *vae)
|
|
|
de47d7 |
return 0;
|
|
|
de47d7 |
}
|
|
|
de47d7 |
|
|
|
de47d7 |
-/*
|
|
|
de47d7 |
- vattr_delete_attrvals
|
|
|
de47d7 |
- ---------------------
|
|
|
de47d7 |
- deletes a value list
|
|
|
de47d7 |
-*/
|
|
|
de47d7 |
-void
|
|
|
de47d7 |
-vattr_delete_attrvals(objAttrValue **attrval)
|
|
|
de47d7 |
-{
|
|
|
de47d7 |
- objAttrValue *val = *attrval;
|
|
|
de47d7 |
-
|
|
|
de47d7 |
- while (val) {
|
|
|
de47d7 |
- objAttrValue *next = val->pNext;
|
|
|
de47d7 |
- slapi_value_free(&val->val);
|
|
|
de47d7 |
- slapi_ch_free((void **)&val;;
|
|
|
de47d7 |
- val = next;
|
|
|
de47d7 |
- }
|
|
|
de47d7 |
-}
|
|
|
de47d7 |
-
|
|
|
de47d7 |
/*
|
|
|
de47d7 |
vattr_add_attrval
|
|
|
de47d7 |
-----------------
|
|
|
de47d7 |
--
|
|
|
de47d7 |
2.25.3
|
|
|
de47d7 |
|