]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9135 fix index error on collapsed range
authorHoward Chu <hyc@openldap.org>
Thu, 13 Aug 2020 17:17:45 +0000 (18:17 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Fri, 28 Aug 2020 01:30:53 +0000 (01:30 +0000)
servers/slapd/back-mdb/idl.c

index 735de653c6da626c99e91e401195cd8b2384b504..26a6373c30dc35160741b61a2f6d9e406a1fd4ad 100644 (file)
@@ -625,9 +625,30 @@ mdb_idl_delete_keys(
                                }
                                if ( lo2 >= hi2 ) {
                                /* The range has collapsed... */
-                                       rc = mdb_cursor_del( cursor, MDB_NODUPDATA );
+                                       /* delete the range marker */
+                                       rc = mdb_cursor_del( cursor, 0 );
                                        if ( rc != 0 ) {
-                                               err = "c_del dup";
+                                               err = "c_del dup1";
+                                               goto fail;
+                                       }
+                                       /* skip past deleted marker */
+                                       rc = mdb_cursor_get( cursor, &key, &data, MDB_NEXT_DUP );
+                                       if ( rc != 0 ) {
+                                               err = "c_get dup1";
+                                               goto fail;
+                                       }
+                                       /* delete the requested id */
+                                       if ( id == hi ) {
+                                               /* skip lo */
+                                               rc = mdb_cursor_get( cursor, &key, &data, MDB_NEXT_DUP );
+                                               if ( rc != 0 ) {
+                                                       err = "c_get dup2";
+                                                       goto fail;
+                                               }
+                                       }
+                                       rc = mdb_cursor_del( cursor, 0 );
+                                       if ( rc != 0 ) {
+                                               err = "c_del dup2";
                                                goto fail;
                                        }
                                } else {