]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10280 more filter choice fixups
authorHoward Chu <hyc@openldap.org>
Mon, 13 Apr 2026 17:50:49 +0000 (18:50 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 28 Apr 2026 18:42:35 +0000 (18:42 +0000)
Make sure they use (f_choice & SLAPD_FILTER_MASK) when needed

servers/slapd/back-asyncmeta/search.c
servers/slapd/back-mdb/filterindex.c
servers/slapd/back-meta/map.c
servers/slapd/back-sql/search.c
servers/slapd/back-wt/filterindex.c
servers/slapd/overlays/rwmmap.c

index 6581b854b3e2e4c0f063364783cb89f52eb8e896..df0c48f21f50c9e478e9bbdb50526ff769918a55 100644 (file)
@@ -86,6 +86,7 @@ asyncmeta_int_filter2bv( a_dncookie           *dc,
                        ber_bvnone = BER_BVC( "(?=none)" );
        ber_len_t       len;
        void *memctx = dc->memctx;
+       ber_tag_t       choice;
 
        assert( fstr != NULL );
        BER_BVZERO( fstr );
@@ -95,7 +96,8 @@ asyncmeta_int_filter2bv( a_dncookie           *dc,
                return LDAP_OTHER;
        }
 
-       switch ( ( f->f_choice & SLAPD_FILTER_MASK ) ) {
+       choice = f->f_choice & SLAPD_FILTER_MASK;
+       switch ( choice ) {
        case LDAP_FILTER_EQUALITY:
                if ( f->f_av_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) {
                        asyncmeta_dn_massage( dc, &f->f_av_value, &vtmp );
@@ -219,8 +221,8 @@ asyncmeta_int_filter2bv( a_dncookie         *dc,
                fstr->bv_val = dc->op->o_tmpalloc( fstr->bv_len + 128, memctx );        /* FIXME: why 128? */
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)",
-                       f->f_choice == LDAP_FILTER_AND ? '&' :
-                       f->f_choice == LDAP_FILTER_OR ? '|' : '!' );
+                       choice == LDAP_FILTER_AND ? '&' :
+                       choice == LDAP_FILTER_OR ? '|' : '!' );
 
                for ( p = f->f_list; p != NULL; p = p->f_next ) {
                        int     rc;
index 008c33805523cb81cfd863f98b6521753b991e3f..c315fdd79bd682e55c57f0df10645461df8a3441 100644 (file)
@@ -117,7 +117,7 @@ mdb_filter_candidates(
                goto out;
        }
 
-       switch ( f->f_choice ) {
+       switch ( f->f_choice & SLAPD_FILTER_MASK ) {
        case SLAPD_FILTER_COMPUTED:
                switch( f->f_result ) {
                case SLAPD_COMPARE_UNDEFINED:
index 7e5b52df4791d04c9dd7843819ca077cfc1ca014..c3d58a98f641e83452e68bf91c0f70e4393fb41b 100644 (file)
@@ -359,6 +359,7 @@ ldap_back_int_filter_map_rewrite(
                        ber_bvunknown = BER_BVC( "(?=unknown)" ),
                        ber_bvnone = BER_BVC( "(?=none)" );
        ber_len_t       len;
+       ber_tag_t       choice;
 
        assert( fstr != NULL );
        BER_BVZERO( fstr );
@@ -368,7 +369,8 @@ ldap_back_int_filter_map_rewrite(
                return LDAP_OTHER;
        }
 
-       switch ( ( f->f_choice & SLAPD_FILTER_MASK ) ) {
+       choice = f->f_choice & SLAPD_FILTER_MASK;
+       switch ( choice ) {
        case LDAP_FILTER_EQUALITY:
                if ( map_attr_value( dc, f->f_av_desc, &atmp,
                                        &f->f_av_value, &vtmp, remap, memctx ) )
@@ -563,8 +565,8 @@ ldap_back_int_filter_map_rewrite(
                fstr->bv_val = ber_memalloc_x( fstr->bv_len + 128, memctx );    /* FIXME: why 128? */
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)",
-                       f->f_choice == LDAP_FILTER_AND ? '&' :
-                       f->f_choice == LDAP_FILTER_OR ? '|' : '!' );
+                       choice == LDAP_FILTER_AND ? '&' :
+                       choice == LDAP_FILTER_OR ? '|' : '!' );
 
                for ( p = f->f_list; p != NULL; p = p->f_next ) {
                        int     rc;
index 257576504fc034121e0e75cc7bdff43b1bd9d9e8..f1e706813ea7d12ceb9364166d412b494c2341be 100644 (file)
@@ -756,9 +756,11 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
        unsigned                i;
        int                     done = 0;
        int                     rc = 0;
+       ber_tag_t       choice;
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_process_filter()\n" );
-       if ( f->f_choice == SLAPD_FILTER_COMPUTED ) {
+       choice = f->f_choice & SLAPD_FILTER_MASK;
+       if ( choice == SLAPD_FILTER_COMPUTED ) {
                struct berval   flt;
                char            *msg = NULL;
 
@@ -801,7 +803,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                goto done;
        }
 
-       switch( f->f_choice ) {
+       switch( choice ) {
        case LDAP_FILTER_OR:
                rc = backsql_process_filter_list( bsi, f->f_or, 
                                LDAP_FILTER_OR );
@@ -877,7 +879,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                 * otherwise, let's see if we are lucky: filtering
                 * for "structural" objectclass or ancestor...
                 */
-               switch ( f->f_choice ) {
+               switch ( choice ) {
                case LDAP_FILTER_EQUALITY:
                {
                        ObjectClass     *oc = oc_bvfind( &f->f_av_value );
@@ -950,7 +952,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                char            keyvalbuf[LDAP_PVT_INTTYPE_CHARS(unsigned long)];
 #endif /* ! BACKSQL_ARBITRARY_KEY */
 
-               switch ( f->f_choice ) {
+               switch ( choice ) {
                case LDAP_FILTER_EQUALITY:
                        backsql_entryUUID_decode( &f->f_av_value, &oc_id, &keyval );
 
@@ -1285,7 +1287,7 @@ backsql_process_filter_attr( backsql_srch_info *bsi, Filter *f, backsql_at_map_r
                return 1;
        }
 
-       switch ( f->f_choice ) {
+       switch ( f->f_choice & SLAPD_FILTER_MASK ) {
        case LDAP_FILTER_EQUALITY:
                filter_value = &f->f_av_value;
                matching_rule = at->bam_ad->ad_type->sat_equality;
index 532b6e452edaf518112963069761895843ab72dc..52e6b6731070f1e34e03b7a2edf1fe0e9d5a6d8d 100644 (file)
@@ -617,7 +617,7 @@ wt_filter_candidates(
                goto done;
        }
 
-       switch ( f->f_choice ) {
+       switch ( f->f_choice & SLAPD_FILTER_MASK ) {
        case SLAPD_FILTER_COMPUTED:
                switch( f->f_result ) {
                case SLAPD_COMPARE_UNDEFINED:
index 85770619159b57d3ce3bdaa442c5a6bb741d7f66..5d35cd5d689802a94a1872cdff8f159cf63d285a 100644 (file)
@@ -537,6 +537,7 @@ rwm_int_filter_map_rewrite(
                        ber_bvunknown = BER_BVC( "(?=unknown)" ),
                        ber_bvnone = BER_BVC( "(?=none)" );
        ber_len_t       len;
+       ber_tag_t       choice;
 
        assert( fstr != NULL );
        BER_BVZERO( fstr );
@@ -553,7 +554,8 @@ rwm_int_filter_map_rewrite(
        }
 #endif
 
-       switch ( f->f_choice & SLAPD_FILTER_MASK ) {
+       choice = f->f_choice & SLAPD_FILTER_MASK;
+       switch ( choice ) {
        case LDAP_FILTER_EQUALITY:
                ad = f->f_av_desc;
                if ( map_attr_value( dc, &ad, &atmp,
@@ -711,8 +713,8 @@ rwm_int_filter_map_rewrite(
                fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 128, op->o_tmpmemctx );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)",
-                       f->f_choice == LDAP_FILTER_AND ? '&' :
-                       f->f_choice == LDAP_FILTER_OR ? '|' : '!' );
+                       choice == LDAP_FILTER_AND ? '&' :
+                       choice == LDAP_FILTER_OR ? '|' : '!' );
 
                for ( p = f->f_list; p != NULL; p = p->f_next ) {
                        int     rc;