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