From 7fdcd2ec608741f5068df3487b23979251a39419 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 16 Jun 2005 19:19:11 +0000 Subject: [PATCH] fix ITS#3785: do our best to deal with invalid filters... --- servers/slapd/back-meta/map.c | 41 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/servers/slapd/back-meta/map.c b/servers/slapd/back-meta/map.c index 62533e339f..87ca4b9031 100644 --- a/servers/slapd/back-meta/map.c +++ b/servers/slapd/back-meta/map.c @@ -483,43 +483,40 @@ ldap_back_int_filter_map_rewrite( ber_memfree( vtmp.bv_val ); break; - case SLAPD_FILTER_COMPUTED: + case SLAPD_FILTER_COMPUTED: { + struct berval bv; + switch ( f->f_result ) { case LDAP_COMPARE_FALSE: if ( dc->target->mt_flags & LDAP_BACK_F_SUPPORT_T_F ) { - ber_str2bv( "(|)", STRLENOF( "(|)" ), 1, fstr ); - - } else { -#if 0 - ber_str2bv( "(?=false)", STRLENOF( "(?=false)" ), 1, fstr ); -#endif - /* better than nothing... */ - ber_str2bv( "(!(objectClass=*))", STRLENOF( "(!(objectClass=*))" ), 1, fstr ); + BER_BVSTR( &bv, "(|)" ); + break; } + /* fallthru */ + + /* FIXME: treat UNDEFINED as FALSE */ + case SLAPD_COMPARE_UNDEFINED: + /* better than nothing... */ + BER_BVSTR( &bv, "(!(objectClass=*))" ); break; case LDAP_COMPARE_TRUE: if ( dc->target->mt_flags & LDAP_BACK_F_SUPPORT_T_F ) { - ber_str2bv( "(&)", STRLENOF( "(&)" ), 1, fstr ); - - } else { -#if 0 - ber_str2bv( "(?=true)", STRLENOF( "(?=true)" ), 1, fstr ); -#endif - /* better than nothing... */ - ber_str2bv( "(objectClass=*)", STRLENOF( "(objectClass=*)" ), 1, fstr ); + BER_BVSTR( &bv, "(&)" ); + break; } - break; - case SLAPD_COMPARE_UNDEFINED: - ber_str2bv( "(?=undefined)", STRLENOF( "(?=undefined)" ), 1, fstr ); + /* better than nothing... */ + BER_BVSTR( &bv, "(objectClass=*)" ); break; default: - ber_str2bv( "(?=error)", STRLENOF( "(?=error)" ), 1, fstr ); + BER_BVSTR( &bv, "(?=error)" ); break; } - break; + + ber_dupbv( fstr, &bv ); + } break; default: ber_str2bv( "(?=unknown)", STRLENOF( "(?=unknown)" ), 1, fstr ); -- 2.39.5