From: Howard Chu Date: Fri, 23 Aug 2002 22:09:40 +0000 (+0000) Subject: Import ITS#2039 index corruption fix from HEAD X-Git-Tag: OPENLDAP_REL_ENG_2_0_26~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70b8218f480bbeacbd86b3daf45864abb4a6eb61;p=thirdparty%2Fopenldap.git Import ITS#2039 index corruption fix from HEAD --- diff --git a/servers/slapd/back-ldbm/idl.c b/servers/slapd/back-ldbm/idl.c index 176f780e42..1ee4a5c13a 100644 --- a/servers/slapd/back-ldbm/idl.c +++ b/servers/slapd/back-ldbm/idl.c @@ -48,17 +48,26 @@ static void cont_free( Datum *cont ) #ifdef LDBM_DEBUG_IDL static void idl_check(ID_BLOCK *idl) { - int i; + int i, max; ID_BLOCK last; - if( ID_BLOCK_INDIRECT(idl) || ID_BLOCK_ALLIDS(idl) - || ID_BLOCK_NIDS(idl) <= 1 ) + if( ID_BLOCK_ALLIDS(idl) ) { return; } + if( ID_BLOCK_INDIRECT(idl) ) + { + for ( max = 0; ID_BLOCK_ID(idl, max) != NOID; max++ ) ; + } else + { + max = ID_BLOCK_NIDS(idl); + } + + if (max <= 1) + return; for( last = ID_BLOCK_ID(idl, 0), i = 1; - i < ID_BLOCK_NIDS(idl); + i < max; last = ID_BLOCK_ID(idl, i), i++ ) { assert (last < ID_BLOCK_ID(idl, i) ); @@ -526,7 +535,7 @@ idl_insert_key( if ( !first && !ID_BLOCK_NOID(idl, i + 1) ) { /* read it in */ cont_alloc( &k2, &key ); - cont_id( &k2, ID_BLOCK_ID(idl, i) ); + cont_id( &k2, ID_BLOCK_ID(idl, i + 1) ); if ( (tmp2 = idl_fetch_one( be, db, k2 )) == NULL ) { Debug( LDAP_DEBUG_ANY, "idl_insert_key: idl_fetch_one returned NULL\n",