Blame SOURCES/slapi-nis-Bug-1725845-slapi-nis-crashes-when-returning-an-entr.patch

9c7f46
From e34a1220d740490a78185fb65bf575766906e419 Mon Sep 17 00:00:00 2001
9c7f46
From: Thierry Bordaz <tbordaz@redhat.com>
9c7f46
Date: Thu, 1 Aug 2019 18:23:14 +0200
9c7f46
Subject: [PATCH 2/2] Bug 1725845: slapi-nis crashes when returning an entry
9c7f46
 with invalid DN
9c7f46
9c7f46
Bug Description:
9c7f46
	On a search on compat tree, slapi-nis prepared the set of entries to return.
9c7f46
	It stores the entries into a hashtable, using the normalized DN as a key.
9c7f46
	If the entry contains an invalid DN, the key is invalid and triggers
9c7f46
	a crash while adding the entry in the hashtable
9c7f46
9c7f46
https://bugzilla.redhat.com/show_bug.cgi?id=1725845
9c7f46
---
9c7f46
 src/back-sch.c | 5 +++--
9c7f46
 1 file changed, 3 insertions(+), 2 deletions(-)
9c7f46
9c7f46
diff --git a/src/back-sch.c b/src/back-sch.c
9c7f46
index 3f7e30f..87fa24c 100644
9c7f46
--- a/src/back-sch.c
9c7f46
+++ b/src/back-sch.c
9c7f46
@@ -1525,16 +1525,17 @@ backend_entries_to_return_push(struct backend_search_cbdata *cbdata, Slapi_Entry
9c7f46
 	struct entries_to_send *e_to_send = NULL;
9c7f46
 	struct cached_entry *entry = NULL;
9c7f46
 	bool_t dont_cache = FALSE;
9c7f46
+	void *ndn_key = (void *) slapi_entry_get_ndn(e);
9c7f46
 	PLHashTable* ht = (PLHashTable*) cbdata->state->cached_entries;
9c7f46
 
9c7f46
-	if ((cbdata == NULL) || (e == NULL)) return;
9c7f46
+	if ((cbdata == NULL) || (e == NULL) || (ndn_key == NULL)) return;
9c7f46
 
9c7f46
 	e_to_send = (struct entries_to_send *) slapi_ch_calloc(1, sizeof(struct entries_to_send));
9c7f46
 
9c7f46
 	dont_cache = cbdata->state->use_entry_cache ? FALSE : TRUE;
9c7f46
 
9c7f46
 	if (!wrap_rwlock_wrlock(cbdata->state->cached_entries_lock)) {
9c7f46
-		entry = PL_HashTableLookup(ht, slapi_entry_get_ndn(e));
9c7f46
+		entry = PL_HashTableLookup(ht, ndn_key);
9c7f46
 		if (entry != NULL) {
9c7f46
 			/* There is an entry in the hash table but is it the same? */
9c7f46
 			char *e_modifyTimestamp = slapi_entry_attr_get_charptr(e, "modifyTimestamp");
9c7f46
-- 
9c7f46
2.21.0
9c7f46