]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#2348 fix from HEAD OPENLDAP_REL_ENG_2
authorHoward Chu <hyc@openldap.org>
Wed, 12 Mar 2003 13:42:29 +0000 (13:42 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 12 Mar 2003 13:42:29 +0000 (13:42 +0000)
servers/slapd/back-ldbm/idl.c

index 64c1cc7087bc9fd97bf7e61b33655819d52c0a37..d87dfa7ee407f858a4b5f6d1bd893ff9537dec57 100644 (file)
@@ -478,15 +478,9 @@ idl_insert_key(
         */
 
        /* select the block to try inserting into *//* XXX linear search XXX */
-       for ( i = 0; !ID_BLOCK_NOID(idl, i) && id > ID_BLOCK_ID(idl, i); i++ )
+       for ( i = 0; !ID_BLOCK_NOID(idl, i) && id >= ID_BLOCK_ID(idl, i); i++ )
                ;       /* NULL */
        
-       /* The ID already exists in the IDL, no insert needed */
-       if ( ID_BLOCK_ID( idl, i ) == id ) {
-               idl_free( idl );
-               return 0;
-       }
-
        if ( i != 0 ) {
                i--;
                first = 0;
@@ -494,6 +488,11 @@ idl_insert_key(
                first = 1;
        }
 
+       /* At this point the following condition must be true:
+        * ID_BLOCK_ID(idl, i) <= id && id < ID_BLOCK_ID(idl, i+1)
+        * except when i is the first or the last block.
+        */
+
        /* get the block */
        cont_alloc( &k2, &key );
        cont_id( &k2, ID_BLOCK_ID(idl, i) );