From 8609e7993237e5ffe54830299212c128e082d9b9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Aug 2005 06:55:40 +0000 Subject: r9318: fix searches with scope ONE and SUB, the problem was that ldb_dn_compare_base() just looked at if both dn's mtach some how, and the following happens: basedn: CN=bar,DC=foo,DC=com dn: DC=foo,DC=com and dn: DC=foo,DC=com was return as result of a sub and base search and also the ONE search with basedn: DC=foo,DC=com returned this dn: CN=bla,CN=bar,DC=foo,DC=com metze (This used to be commit 2a107472c373e425013050e28b944c830f653a87) --- source4/lib/ldb/common/ldb_dn.c | 4 ++++ source4/lib/ldb/common/ldb_match.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index edb5124d99..5dcb540fa1 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -415,6 +415,10 @@ int ldb_dn_compare_base(struct ldb_context *ldb, int ret; int n0, n1; + if (base->comp_num > dn->comp_num) { + return (dn->comp_num - base->comp_num); + } + /* if the number of components doesn't match they differ */ n0 = base->comp_num - 1; n1 = dn->comp_num - 1; diff --git a/source4/lib/ldb/common/ldb_match.c b/source4/lib/ldb/common/ldb_match.c index 7ff84f70c3..b6f5f5a18d 100644 --- a/source4/lib/ldb/common/ldb_match.c +++ b/source4/lib/ldb/common/ldb_match.c @@ -71,7 +71,7 @@ static int ldb_match_scope(struct ldb_context *ldb, break; case LDB_SCOPE_ONELEVEL: - if (dn->comp_num != base->comp_num) { + if (dn->comp_num == (base->comp_num + 1)) { if (ldb_dn_compare_base(ldb, base, dn) == 0) { ret = 1; } -- cgit