From 70e73a45d9e473777eb3eecbd3babc397292da71 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Oct 2005 11:27:29 +0000 Subject: r11111: fixed a talloc error in the dn shortcut code (This used to be commit e28a334eeb8fa22f686d0c1dc48b2977d85b9e10) --- source4/lib/ldb/ldb_tdb/ldb_index.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/ldb_tdb') diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index e80cf74c62..275aadbd78 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -323,9 +323,17 @@ static int ltdb_index_dn_leaf(struct ldb_module *module, } if (ldb_attr_cmp(tree->u.equality.attr, "distinguishedName") == 0 || ldb_attr_cmp(tree->u.equality.attr, "dn") == 0) { - char *dn = talloc_strdup(list, (char *)tree->u.equality.value.data); + list->dn = talloc_array(list, char *, 1); + if (list->dn == NULL) { + ldb_oom(module->ldb); + return -1; + } + list->dn[0] = talloc_strdup(list, (char *)tree->u.equality.value.data); + if (list->dn[0] == NULL) { + ldb_oom(module->ldb); + return -1; + } list->count = 1; - list->dn = &dn; return 1; } return ltdb_index_dn_simple(module, tree, index_list, list); @@ -698,12 +706,17 @@ int ltdb_search_indexed(struct ldb_module *module, if (scope == LDB_SCOPE_BASE) { /* with BASE searches only one DN can match */ - char *dn = ldb_dn_linearize(dn_list, base); - if (dn == NULL) { + dn_list->dn = talloc_array(dn_list, char *, 1); + if (dn_list->dn == NULL) { + ldb_oom(module->ldb); + return -1; + } + dn_list->dn[0] = ldb_dn_linearize(dn_list, base); + if (dn_list->dn[0] == NULL) { + ldb_oom(module->ldb); return -1; } dn_list->count = 1; - dn_list->dn = &dn; ret = 1; } else { ret = ltdb_index_dn(module, tree, ltdb->cache->indexlist, dn_list); -- cgit