mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-28 02:29:34 -05:00
Fix HDB search_aliases crash, cleanup search scope processing: call dn2idl
directly instead of going thru filter_candidates. Use hdb_ function prefix in dn2id.c to avoid ambiguities...
This commit is contained in:
parent
bb9d3ff304
commit
759996c6e9
4 changed files with 58 additions and 70 deletions
|
|
@ -412,27 +412,27 @@ bdb_dn2id_children(
|
|||
|
||||
int
|
||||
bdb_dn2idl(
|
||||
BackendDB *be,
|
||||
struct berval *dn,
|
||||
int prefix,
|
||||
Operation *op,
|
||||
Entry *e,
|
||||
ID *ids,
|
||||
ID *stack,
|
||||
void *ctx )
|
||||
ID *stack )
|
||||
{
|
||||
int rc;
|
||||
DBT key;
|
||||
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
||||
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
|
||||
DB *db = bdb->bi_dn2id->bdi_db;
|
||||
int prefix = op->ors_scope == LDAP_SCOPE_SUBTREE ? DN_SUBTREE_PREFIX :
|
||||
DN_ONE_PREFIX;
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG ( INDEX, ARGS,
|
||||
"=> bdb_dn2ididl( \"%s\" )\n", dn->bv_val, 0, 0 );
|
||||
"=> bdb_dn2ididl( \"%s\" )\n", e->e_nname.bv_val, 0, 0 );
|
||||
#else
|
||||
Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2idl( \"%s\" )\n", dn->bv_val, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2idl( \"%s\" )\n", e->e_nname.bv_val, 0, 0 );
|
||||
#endif
|
||||
|
||||
#ifndef BDB_MULTIPLE_SUFFIXES
|
||||
if (prefix == DN_SUBTREE_PREFIX && be_issuffix(be, dn))
|
||||
if (prefix == DN_SUBTREE_PREFIX && BEI(e)->bei_parent->bei_id == 0 )
|
||||
{
|
||||
BDB_IDL_ALL(bdb, ids);
|
||||
return 0;
|
||||
|
|
@ -440,14 +440,14 @@ bdb_dn2idl(
|
|||
#endif
|
||||
|
||||
DBTzero( &key );
|
||||
key.size = dn->bv_len + 2;
|
||||
key.size = e->e_nname.bv_len + 2;
|
||||
key.ulen = key.size;
|
||||
key.flags = DB_DBT_USERMEM;
|
||||
key.data = sl_malloc( key.size, ctx );
|
||||
key.data = sl_malloc( key.size, op->o_tmpmemctx );
|
||||
((char *)key.data)[0] = prefix;
|
||||
AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
|
||||
AC_MEMCPY( &((char *)key.data)[1], e->e_nname.bv_val, key.size - 1 );
|
||||
|
||||
rc = bdb_idl_fetch_key( be, db, NULL, &key, ids );
|
||||
rc = bdb_idl_fetch_key( op->o_bd, db, NULL, &key, ids );
|
||||
|
||||
if( rc != 0 ) {
|
||||
#ifdef NEW_LOGGING
|
||||
|
|
@ -473,7 +473,7 @@ bdb_dn2idl(
|
|||
#endif
|
||||
}
|
||||
|
||||
sl_free( key.data, ctx );
|
||||
sl_free( key.data, op->o_tmpmemctx );
|
||||
return rc;
|
||||
}
|
||||
#else /* BDB_HIER */
|
||||
|
|
@ -506,7 +506,7 @@ typedef struct diskNode {
|
|||
* Sorts based on normalized RDN, in length order.
|
||||
*/
|
||||
int
|
||||
bdb_dup_compare(
|
||||
hdb_dup_compare(
|
||||
DB *db,
|
||||
const DBT *usrkey,
|
||||
const DBT *curkey
|
||||
|
|
@ -531,7 +531,7 @@ bdb_dup_compare(
|
|||
|
||||
/* This function constructs a full DN for a given entry.
|
||||
*/
|
||||
int bdb_fix_dn(
|
||||
int hdb_fix_dn(
|
||||
Entry *e,
|
||||
int checkit
|
||||
)
|
||||
|
|
@ -540,7 +540,8 @@ int bdb_fix_dn(
|
|||
int rlen = 0, nrlen = 0;
|
||||
char *ptr, *nptr;
|
||||
int max = 0;
|
||||
|
||||
|
||||
/* count length of all DN components */
|
||||
for ( ei = BEI(e); ei && ei->bei_id; ei=ei->bei_parent ) {
|
||||
rlen += ei->bei_rdn.bv_len + 1;
|
||||
nrlen += ei->bei_nrdn.bv_len + 1;
|
||||
|
|
@ -586,7 +587,7 @@ int bdb_fix_dn(
|
|||
* child's entryID containing the parent's entryID.
|
||||
*/
|
||||
int
|
||||
bdb_dn2id_add(
|
||||
hdb_dn2id_add(
|
||||
BackendDB *be,
|
||||
DB_TXN *txn,
|
||||
EntryInfo *eip,
|
||||
|
|
@ -647,7 +648,7 @@ bdb_dn2id_add(
|
|||
}
|
||||
|
||||
int
|
||||
bdb_dn2id_delete(
|
||||
hdb_dn2id_delete(
|
||||
BackendDB *be,
|
||||
DB_TXN *txn,
|
||||
EntryInfo *eip,
|
||||
|
|
@ -709,7 +710,7 @@ bdb_dn2id_delete(
|
|||
}
|
||||
|
||||
int
|
||||
bdb_dn2id(
|
||||
hdb_dn2id(
|
||||
BackendDB *be,
|
||||
DB_TXN *txn,
|
||||
struct berval *in,
|
||||
|
|
@ -764,7 +765,7 @@ bdb_dn2id(
|
|||
}
|
||||
|
||||
int
|
||||
bdb_dn2id_parent(
|
||||
hdb_dn2id_parent(
|
||||
Backend *be,
|
||||
DB_TXN *txn,
|
||||
EntryInfo *ei,
|
||||
|
|
@ -815,7 +816,7 @@ bdb_dn2id_parent(
|
|||
}
|
||||
|
||||
int
|
||||
bdb_dn2id_children(
|
||||
hdb_dn2id_children(
|
||||
Operation *op,
|
||||
DB_TXN *txn,
|
||||
Entry *e )
|
||||
|
|
@ -886,7 +887,7 @@ struct dn2id_cookie {
|
|||
};
|
||||
|
||||
static int
|
||||
bdb_dn2idl_internal(
|
||||
hdb_dn2idl_internal(
|
||||
struct dn2id_cookie *cx
|
||||
)
|
||||
{
|
||||
|
|
@ -960,7 +961,7 @@ saveit:
|
|||
for ( cx->id = bdb_idl_first( save, &idcurs );
|
||||
cx->id != NOID;
|
||||
cx->id = bdb_idl_next( save, &idcurs )) {
|
||||
bdb_dn2idl_internal( cx );
|
||||
hdb_dn2idl_internal( cx );
|
||||
}
|
||||
sl_free( save, cx->ctx );
|
||||
cx->rc = 0;
|
||||
|
|
@ -972,35 +973,41 @@ saveit:
|
|||
}
|
||||
|
||||
int
|
||||
bdb_dn2idl(
|
||||
BackendDB *be,
|
||||
struct berval *dn,
|
||||
int prefix,
|
||||
hdb_dn2idl(
|
||||
Operation *op,
|
||||
Entry *e,
|
||||
ID *ids,
|
||||
ID *stack,
|
||||
void *ctx )
|
||||
ID *stack )
|
||||
{
|
||||
struct bdb_info *bdb = (struct bdb_info *)op->o_bd->be_private;
|
||||
struct dn2id_cookie cx;
|
||||
EntryInfo *ei = (EntryInfo *)dn;
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG ( INDEX, ARGS,
|
||||
"=> hdb_dn2ididl( \"%s\" )\n", e->e_nname.bv_val, 0, 0 );
|
||||
#else
|
||||
Debug( LDAP_DEBUG_TRACE, "=> hdb_dn2idl( \"%s\" )\n", e->e_nname.bv_val, 0, 0 );
|
||||
#endif
|
||||
|
||||
#ifndef BDB_MULTIPLE_SUFFIXES
|
||||
if ( ei->bei_parent->bei_id == 0 ) {
|
||||
struct bdb_info *bdb = (struct bdb_info *)be->be_private;
|
||||
if ( op->ors_scope == LDAP_SCOPE_SUBTREE &&
|
||||
BEI(e)->bei_parent->bei_id == 0 ) {
|
||||
BDB_IDL_ALL( bdb, ids );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
cx.id = ei->bei_id;
|
||||
cx.bdb = (struct bdb_info *)be->be_private;
|
||||
cx.id = e->e_id;
|
||||
cx.bdb = bdb;
|
||||
cx.db = cx.bdb->bi_dn2id->bdi_db;
|
||||
cx.prefix = prefix;
|
||||
cx.prefix = op->ors_scope == LDAP_SCOPE_SUBTREE ? DN_SUBTREE_PREFIX :
|
||||
DN_ONE_PREFIX;
|
||||
cx.ids = ids;
|
||||
cx.buf = stack;
|
||||
cx.ctx = ctx;
|
||||
cx.ctx = op->o_tmpmemctx;
|
||||
|
||||
BDB_IDL_ZERO( ids );
|
||||
if ( prefix == DN_SUBTREE_PREFIX ) {
|
||||
if ( cx.prefix == DN_SUBTREE_PREFIX ) {
|
||||
bdb_idl_insert( ids, cx.id );
|
||||
}
|
||||
|
||||
|
|
@ -1012,6 +1019,6 @@ bdb_dn2idl(
|
|||
|
||||
DBTzero(&cx.data);
|
||||
|
||||
return bdb_dn2idl_internal(&cx);
|
||||
return hdb_dn2idl_internal(&cx);
|
||||
}
|
||||
#endif /* BDB_HIER */
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ bdb_filter_candidates(
|
|||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
#if 0 /* Not used any more, search calls bdb_dn2idl directly */
|
||||
case SLAPD_FILTER_DN_ONE:
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN ONE\n", 0, 0, 0 );
|
||||
|
|
@ -95,7 +95,7 @@ bdb_filter_candidates(
|
|||
rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, ids,
|
||||
stack, op->o_tmpmemctx );
|
||||
break;
|
||||
|
||||
#endif
|
||||
case LDAP_FILTER_PRESENT:
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tPRESENT\n", 0, 0, 0 );
|
||||
|
|
|
|||
|
|
@ -90,12 +90,10 @@ int bdb_dn2id_children(
|
|||
Entry *e );
|
||||
|
||||
int bdb_dn2idl(
|
||||
BackendDB *be,
|
||||
struct berval *dn,
|
||||
int prefix,
|
||||
Operation *op,
|
||||
Entry *e,
|
||||
ID *ids,
|
||||
ID *stack,
|
||||
void *ctx );
|
||||
ID *stack );
|
||||
|
||||
#ifdef BDB_HIER
|
||||
#define bdb_dn2id_parent BDB_SYMBOL(dn2id_parent)
|
||||
|
|
|
|||
|
|
@ -119,14 +119,14 @@ static Entry * deref_base (
|
|||
|
||||
/* Look for and dereference all aliases within the search scope. Adds
|
||||
* the dereferenced entries to the "ids" list. Requires "stack" to be
|
||||
* able to hold 8 levels of DB_SIZE IDLs.
|
||||
* able to hold 8 levels of DB_SIZE IDLs. Of course we're hardcoded to
|
||||
* require a minimum of 8 UM_SIZE IDLs so this is never a problem.
|
||||
*/
|
||||
static int search_aliases(
|
||||
Operation *op,
|
||||
SlapReply *rs,
|
||||
Entry *e,
|
||||
u_int32_t locker,
|
||||
Filter *sf,
|
||||
ID *ids,
|
||||
ID *scopes,
|
||||
ID *stack
|
||||
|
|
@ -143,7 +143,6 @@ static int search_aliases(
|
|||
DB_LOCK locka, lockr;
|
||||
int first = 1;
|
||||
|
||||
|
||||
aliases = stack; /* IDL of all aliases in the database */
|
||||
curscop = aliases + BDB_IDL_DB_SIZE; /* Aliases in the current scope */
|
||||
subscop = curscop + BDB_IDL_DB_SIZE; /* The current scope */
|
||||
|
|
@ -187,7 +186,8 @@ static int search_aliases(
|
|||
* to the cumulative list of candidates.
|
||||
*/
|
||||
BDB_IDL_CPY( curscop, aliases );
|
||||
rs->sr_err = bdb_filter_candidates( op, sf, subscop, NULL, NULL );
|
||||
rs->sr_err = bdb_dn2idl( op, e, subscop,
|
||||
subscop2+BDB_IDL_DB_SIZE );
|
||||
if (first) {
|
||||
first = 0;
|
||||
} else {
|
||||
|
|
@ -273,12 +273,6 @@ nextido:
|
|||
0, locker, &locka, op->o_tmpmemctx );
|
||||
if (rs->sr_err != LDAP_SUCCESS) goto nextido;
|
||||
e = ei->bei_e;
|
||||
#ifndef BDB_HIER
|
||||
sf->f_dn = &e->e_nname;
|
||||
#else
|
||||
/* bdb_dn2idl uses IDs for keys, not DNs */
|
||||
sf->f_dn = (struct berval *)ei;
|
||||
#endif
|
||||
}
|
||||
return rs->sr_err;
|
||||
}
|
||||
|
|
@ -1508,7 +1502,7 @@ static int search_candidates(
|
|||
{
|
||||
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
|
||||
int rc, depth = 1;
|
||||
Filter f, scopef, rf, xf, nf;
|
||||
Filter f, rf, xf, nf;
|
||||
ID *stack;
|
||||
AttributeAssertion aa_ref;
|
||||
#ifdef BDB_SUBENTRIES
|
||||
|
|
@ -1557,16 +1551,6 @@ static int search_candidates(
|
|||
}
|
||||
}
|
||||
|
||||
scopef.f_choice = op->oq_search.rs_scope == LDAP_SCOPE_SUBTREE
|
||||
? SLAPD_FILTER_DN_SUBTREE
|
||||
: SLAPD_FILTER_DN_ONE;
|
||||
#ifdef BDB_HIER
|
||||
scopef.f_dn = (struct berval *)e->e_private;
|
||||
#else
|
||||
scopef.f_dn = &e->e_nname;
|
||||
#endif
|
||||
scopef.f_next = NULL;
|
||||
|
||||
f.f_next = NULL;
|
||||
f.f_choice = LDAP_FILTER_AND;
|
||||
f.f_and = &nf;
|
||||
|
|
@ -1598,10 +1582,9 @@ static int search_candidates(
|
|||
}
|
||||
|
||||
if( op->ors_deref & LDAP_DEREF_SEARCHING ) {
|
||||
rc = search_aliases( op, rs, e, locker, &scopef, ids, scopes, stack );
|
||||
rc = search_aliases( op, rs, e, locker, ids, scopes, stack );
|
||||
} else {
|
||||
rc = bdb_filter_candidates( op, &scopef, ids,
|
||||
stack, stack+BDB_IDL_UM_SIZE );
|
||||
rc = bdb_dn2idl( op, e, ids, stack );
|
||||
}
|
||||
|
||||
if ( rc == LDAP_SUCCESS ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue