From 1a52b03b2f4c1503b52784f1a01f8291b78e7604 Mon Sep 17 00:00:00 2001 From: Gary Lockyer Date: Fri, 21 Jun 2019 14:52:24 +1200 Subject: [PATCH] lib ldb key value: Remove check_parent from ldb_kv_index_idxptr() The callers will soon have two possible parents for this pointer, so we need to remove this check, which was added out of caution given the rather strange pattern of putting an active memory pointer into a TDB (as a hash map). That is, the only callers that did call this with "true" would have to call this with "false", so just remove the complexity. Signed-off-by: Andrew Bartlett Signed-off-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- lib/ldb/ldb_key_value/ldb_kv_index.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/ldb/ldb_key_value/ldb_kv_index.c b/lib/ldb/ldb_key_value/ldb_kv_index.c index d0916387b11..5697c2f9c43 100644 --- a/lib/ldb/ldb_key_value/ldb_kv_index.c +++ b/lib/ldb/ldb_key_value/ldb_kv_index.c @@ -325,8 +325,7 @@ static int ldb_kv_dn_list_find_msg(struct ldb_kv_private *ldb_kv, alignment */ static struct dn_list *ldb_kv_index_idxptr(struct ldb_module *module, - TDB_DATA rec, - bool check_parent) + TDB_DATA rec) { struct dn_list *list; if (rec.dsize != sizeof(void *)) { @@ -345,12 +344,6 @@ static struct dn_list *ldb_kv_index_idxptr(struct ldb_module *module, talloc_get_name(list)); return NULL; } - if (check_parent && list->dn && talloc_parent(list->dn) != list) { - ldb_asprintf_errstring(ldb_module_get_ctx(module), - "Bad parent '%s' for idxptr", - talloc_get_name(talloc_parent(list->dn))); - return NULL; - } return list; } @@ -387,7 +380,7 @@ static int ldb_kv_dn_list_load(struct ldb_module *module, } /* we've found an in-memory index entry */ - list2 = ldb_kv_index_idxptr(module, rec, true); + list2 = ldb_kv_index_idxptr(module, rec); if (list2 == NULL) { free(rec.dptr); return LDB_ERR_OPERATIONS_ERROR; @@ -741,7 +734,7 @@ static int ldb_kv_dn_list_store(struct ldb_module *module, rec = tdb_fetch(ldb_kv->idxptr->itdb, key); if (rec.dptr != NULL) { - list2 = ldb_kv_index_idxptr(module, rec, false); + list2 = ldb_kv_index_idxptr(module, rec); if (list2 == NULL) { free(rec.dptr); return LDB_ERR_OPERATIONS_ERROR; @@ -790,7 +783,7 @@ static int ldb_kv_index_traverse_store(_UNUSED_ struct tdb_context *tdb, struct ldb_val v; struct dn_list *list; - list = ldb_kv_index_idxptr(module, data, true); + list = ldb_kv_index_idxptr(module, data); if (list == NULL) { ldb_kv->idxptr->error = LDB_ERR_OPERATIONS_ERROR; return -1; -- 2.34.1