From 5fc7217f1b4a8e72b93fd9e1e9b750cd2a63cce8 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 22 Jan 2002 08:18:12 +0000 Subject: [PATCH] final dn_parent elimination in back-bdb --- servers/slapd/back-bdb/search.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index ec841d7597..9b9272610b 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -346,9 +346,12 @@ bdb_search( /* need to skip alias which deref into scope */ if( scope & LDAP_SCOPE_ONELEVEL ) { - char *pdn = dn_parent( NULL, e->e_ndn ); - if ( pdn != NULL ) { - if( strcmp( pdn, realbase.bv_val ) ) { + char *pdn; + ber_len_t plen; + + if ( dnParent( e->e_nname.bv_val, &pdn ) == LDAP_SUCCESS ) { + plen = e->e_nname.bv_len - ( pdn - e->e_nname.bv_val ); + if ( plen != realbase.bv_len || strcmp( pdn, realbase.bv_val ) ) { goto loop_continue; } } @@ -396,12 +399,13 @@ bdb_search( /* check scope */ if ( !scopeok && scope == LDAP_SCOPE_ONELEVEL ) { - if ( (dn = dn_parent( be, e->e_ndn )) != NULL ) { + if ( be_issuffix( be, e->e_nname.bv_val ) ) { + scopeok = (realbase.bv_len == 0); + } else { + dnParent( e->e_nname.bv_val, (const char **)&dn ); scopeok = (dn == realbase.bv_val) ? 1 : (strcmp( dn, realbase.bv_val ) ? 0 : 1 ); - } else { - scopeok = (realbase.bv_len == 0); } } else if ( !scopeok && scope == LDAP_SCOPE_SUBTREE ) { -- 2.39.5