summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-09-30 23:47:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:16 -0500
commit5ed07022b04bdbb42b7404146c7978b5de0745c0 (patch)
tree5fc981ad14bd586cf9ad6c8108dae6a1ca93069d /source4/lib
parenta788d01b871a7e5813ac3934bcb0ba33fe711aa2 (diff)
downloadsamba-5ed07022b04bdbb42b7404146c7978b5de0745c0.tar.gz
samba-5ed07022b04bdbb42b7404146c7978b5de0745c0.tar.bz2
samba-5ed07022b04bdbb42b7404146c7978b5de0745c0.zip
r10667: cope with a NULL tree for base searches in ldb_search()
(This used to be commit 26ff53857802ae4a63f2b6e46c9caa7ca2fbbe89)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 9af62c7754..574d9485f8 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -501,6 +501,17 @@ int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
if ((base == NULL || base->comp_num == 0) &&
(scope == LDB_SCOPE_BASE || scope == LDB_SCOPE_ONELEVEL)) return -1;
+ /* check if we are looking for a simple dn */
+ if (scope == LDB_SCOPE_BASE && tree == NULL) {
+ return ltdb_search_dn(module, base, attrs, res);
+ }
+
+ if (tree == NULL) {
+ char *err_string = talloc_strdup(module, "expression parse failed");
+ if (err_string) ldb_set_errstring(module, err_string);
+ return -1;
+ }
+
/* it is important that we handle dn queries this way, and not
via a full db search, otherwise ldb is horribly slow */
if (tree->operation == LDB_OP_EQUALITY &&
@@ -553,18 +564,7 @@ int ltdb_search(struct ldb_module *module, const struct ldb_dn *base,
if ((base == NULL || base->comp_num == 0) &&
(scope == LDB_SCOPE_BASE || scope == LDB_SCOPE_ONELEVEL)) return -1;
- /* check if we are looking for a simple dn */
- if (scope == LDB_SCOPE_BASE && (expression == NULL || expression[0] == '\0')) {
- ret = ltdb_search_dn(module, base, attrs, res);
- return ret;
- }
-
tree = ldb_parse_tree(ltdb, expression);
- if (tree == NULL) {
- char *err_string = talloc_strdup(module, "expression parse failed");
- if (err_string) ldb_set_errstring(module, err_string);
- return -1;
- }
ret = ltdb_search_bytree(module, base, scope, tree, attrs, res);
talloc_free(tree);