From 67a65ec701152780522ce6b07d8bdb73f4de4145 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Sun, 4 Jan 2015 07:41:04 +0000 Subject: [PATCH] ITS#8011: few corrections for lmdb-backend; dn2id.c: + assertion for mdb_id2l_insert() result; - unnecessary assignment; search.c: - unused variable 'first'; + range-check for mdb_idl_search() result; --- servers/slapd/back-mdb/dn2id.c | 8 +++++--- servers/slapd/back-mdb/search.c | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/servers/slapd/back-mdb/dn2id.c b/servers/slapd/back-mdb/dn2id.c index 41c4758f95..46637c1234 100644 --- a/servers/slapd/back-mdb/dn2id.c +++ b/servers/slapd/back-mdb/dn2id.c @@ -760,9 +760,11 @@ mdb_idscopes( if ( x <= isc->scopes[0].mid && isc->scopes[x].mid == id ) { if ( !isc->scopes[x].mval.mv_data ) { /* This node is in scope, add parent chain to scope */ - int i = isc->sctmp[0].mid; - for ( i = 1; i <= isc->sctmp[0].mid; i++ ) - mdb_id2l_insert( isc->scopes, &isc->sctmp[i] ); + int i; + for ( i = 1; i <= isc->sctmp[0].mid; i++ ) { + rc = mdb_id2l_insert( isc->scopes, &isc->sctmp[i] ); + assert(rc == 0); + } /* check id again since inserts may have changed its position */ if ( isc->scopes[x].mid != id ) x = mdb_id2l_search( isc->scopes, id ); diff --git a/servers/slapd/back-mdb/search.c b/servers/slapd/back-mdb/search.c index 9089016ba6..185d9f1cc5 100644 --- a/servers/slapd/back-mdb/search.c +++ b/servers/slapd/back-mdb/search.c @@ -140,7 +140,6 @@ static int search_aliases( struct berval bv_alias = BER_BVC( "alias" ); AttributeAssertion aa_alias = ATTRIBUTEASSERTION_INIT; Filter af; - int first = 1; aliases = stack; /* IDL of all aliases in the database */ curscop = aliases + MDB_IDL_DB_SIZE; /* Aliases in the current scope */ @@ -807,7 +806,7 @@ loop_begin: scopeok = 1; } else { i = mdb_idl_search( candidates, id ); - if ( candidates[i] == id ) + if (i <= candidates[0] && candidates[i] == id ) scopeok = 1; } if ( scopeok ) -- 2.39.5