]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
fix idl intersection ITS#10233
authorHAMANO Tsukasa <hamano@osstech.co.jp>
Wed, 26 Jun 2024 01:51:17 +0000 (10:51 +0900)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 8 Jul 2024 13:06:53 +0000 (13:06 +0000)
The `mdb_idl_intersection()` and `wt_idl_intersection()` functions derived from back-bdb return wrong results.

expect:
[1, 3] ∩ [2] = []

actual:
[1, 3] ∩ [2] = [2]

also
- Add scope checking for back-wt
- fix compiler warning

servers/slapd/back-mdb/idl.c
servers/slapd/back-wt/id2entry.c
servers/slapd/back-wt/idl.c
servers/slapd/back-wt/search.c

index c433372cc7812b4b44cbac787c66f9fcbeb20ae4..6ed2c19f683c2bc3f69c3843ccb67512e1cc5600 100644 (file)
@@ -727,7 +727,9 @@ mdb_idl_intersection(
        if ( idmin > idmax ) {
                a[0] = 0;
                return 0;
-       } else if ( idmin == idmax ) {
+       } else if ( idmin == idmax &&
+                       (( MDB_IDL_FIRST(a) == MDB_IDL_LAST(b)) ||
+                       ( MDB_IDL_FIRST(b) == MDB_IDL_LAST(a)))) {
                a[0] = 1;
                a[1] = idmin;
                return 0;
index a9bba1837b5f2ef849367e0593cd6707deb22e98..558abcee4692ca775ad9e741c79d4830e03f447d 100644 (file)
@@ -232,7 +232,7 @@ int wt_entry_return(
                return 0;
        }
 
-    /* Our entries are allocated in two blocks; the data comes from
+       /* Our entries are allocated in two blocks; the data comes from
         * the db itself and the Entry structure and associated pointers
         * are allocated in entry_decode. The db data pointer is saved
         * in e_bv.
@@ -256,6 +256,7 @@ int wt_entry_return(
        }
 
        entry_free( e );
+       return 0;
 }
 
 int wt_entry_release(
index c42aa3a07c6a0275029b0afd28c5b3345d288d77..7c670f188e8296424bfd9b2cfc4f8e2191946c5d 100644 (file)
@@ -53,13 +53,10 @@ void wt_idl_dump( ID *ids )
 
        } else {
                ID i;
-               Debug( LDAP_DEBUG_ANY, "IDL: size %ld", (long) ids[0] );
+               Debug( LDAP_DEBUG_ANY, "IDL: size %ld\n", (long) ids[0] );
 
                for( i=1; i<=ids[0]; i++ ) {
-                       if( i % 16 == 1 ) {
-                               Debug( LDAP_DEBUG_ANY, "\n" );
-                       }
-                       Debug( LDAP_DEBUG_ANY, "  %02lx", (long) ids[i] );
+                       Debug( LDAP_DEBUG_ANY, "  %ld\n", (long) ids[i] );
                }
 
                Debug( LDAP_DEBUG_ANY, "\n" );
@@ -282,7 +279,9 @@ wt_idl_intersection(
        if ( idmin > idmax ) {
                a[0] = 0;
                return 0;
-       } else if ( idmin == idmax ) {
+       } else if ( idmin == idmax &&
+                       (( WT_IDL_FIRST(a) == WT_IDL_LAST(b)) ||
+                       ( WT_IDL_FIRST(b) == WT_IDL_LAST(a)))) {
                a[0] = 1;
                a[1] = idmin;
                return 0;
index f4c2edef754031c512e595fd52db71ae3d007080..f2ed75de4b3b3faf3e31ab612bd56381ca413e04 100644 (file)
@@ -603,7 +603,7 @@ loop_begin:
                        if ( id == base->e_id ) scopeok = 1;
                        break;
                case LDAP_SCOPE_ONELEVEL:
-                       scopeok = 1;
+                       scopeok = dnIsSuffixScope(&e->e_nname, &base->e_nname, LDAP_SCOPE_ONELEVEL);
                        break;
                case LDAP_SCOPE_CHILDREN:
                        if ( id == base->e_id ) break;