This is a multi-part message in MIME format. --------------060206050400040309010905 Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit
The attached files is derived from OpenLDAP Software. All of the modifications to OpenLDAP Software represented in the following patch(es) were developed by Peter-Service LLC, Moscow, Russia. Peter-Service LLC has not assigned rights and/or interest in this work to any party. I, Leonid Yuriev am authorized by Peter-Service LLC, my employer, to release this work under the following terms.
Peter-Service LLC hereby places the following modifications to OpenLDAP Software (and only these modifications) into the public domain. Hence, these modifications may be freely used and/or redistributed for any purpose with or without attribution and/or other notice.
--------------060206050400040309010905 Content-Type: text/x-patch; name="ITS8011.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ITS8011.patch"
commit 1bdae5a756d803961db4d2c7f6d13e975f89f1f8 Author: Leo Yuriev leo@yuriev.ru Date: 2014-12-28 23:14:52 +0300
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; * fix sctmp/stack allocation size;
diff --git a/servers/slapd/back-mdb/dn2id.c b/servers/slapd/back-mdb/dn2id.c index 41c4758..0890bce 100644 --- a/servers/slapd/back-mdb/dn2id.c +++ b/servers/slapd/back-mdb/dn2id.c @@ -746,7 +746,8 @@ mdb_idscopes( /* remember our chain of parents */ id2.mid = id; id2.mval = data; - mdb_id2l_insert( isc->sctmp, &id2 ); + rc = mdb_id2l_insert( isc->sctmp, &id2 ); + assert(rc == 0); } ptr = data.mv_data; ptr += data.mv_size - sizeof(ID); @@ -760,9 +761,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 9089016..8bcdc10 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 ) @@ -1265,8 +1264,10 @@ static void *search_stack( Operation *op ) }
if ( !ret ) { - ret = ch_malloc( mdb->mi_search_stack_depth * MDB_IDL_UM_SIZE - * sizeof( ID ) ); + size_t case_stack = mdb->mi_search_stack_depth * MDB_IDL_UM_SIZE * sizeof( ID ); + size_t case_sctmp = MDB_IDL_UM_SIZE * sizeof( ID2 ); + size_t size = (case_stack > case_sctmp) ? case_stack : case_sctmp; + ret = ch_malloc( size ); if ( op->o_threadctx ) { ldap_pvt_thread_pool_setkey( op->o_threadctx, (void *)search_stack, ret, search_stack_free, NULL, NULL );
--------------060206050400040309010905--