From 8ef04ec0b460776bf6f1173e0b0c190471cee9a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Mon, 11 Apr 2022 16:57:59 +0100 Subject: [PATCH] ITS#9818 Duplicate substring filters correctly --- servers/slapd/overlays/translucent.c | 24 +++++++++++++++++++++++- tests/scripts/test034-translucent | 8 ++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/servers/slapd/overlays/translucent.c b/servers/slapd/overlays/translucent.c index 1e4e33879c..a034a5859a 100644 --- a/servers/slapd/overlays/translucent.c +++ b/servers/slapd/overlays/translucent.c @@ -999,7 +999,6 @@ trans_filter_dup(Operation *op, Filter *f, AttributeName *an) case LDAP_FILTER_GE: case LDAP_FILTER_LE: case LDAP_FILTER_APPROX: - case LDAP_FILTER_SUBSTRINGS: case LDAP_FILTER_EXT: if ( !f->f_av_desc || ad_inlist( f->f_av_desc, an )) { AttributeAssertion *nava; @@ -1016,6 +1015,29 @@ trans_filter_dup(Operation *op, Filter *f, AttributeName *an) } break; + case LDAP_FILTER_SUBSTRINGS: + if ( !f->f_av_desc || ad_inlist( f->f_av_desc, an )) { + SubstringsAssertion *nsub; + + n = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); + n->f_choice = f->f_choice; + + nsub = op->o_tmpalloc( sizeof(SubstringsAssertion), op->o_tmpmemctx ); + *nsub = *f->f_sub; + n->f_sub = nsub; + + if ( !BER_BVISNULL( &f->f_sub_initial )) + ber_dupbv_x( &n->f_sub_initial, &f->f_sub_initial, op->o_tmpmemctx ); + + ber_bvarray_dup_x( &n->f_sub_any, f->f_sub_any, op->o_tmpmemctx ); + + if ( !BER_BVISNULL( &f->f_sub_final )) + ber_dupbv_x( &n->f_sub_final, &f->f_sub_final, op->o_tmpmemctx ); + + n->f_next = NULL; + } + break; + case LDAP_FILTER_AND: case LDAP_FILTER_OR: case LDAP_FILTER_NOT: { diff --git a/tests/scripts/test034-translucent b/tests/scripts/test034-translucent index 511ebeddcd..8b834d989c 100755 --- a/tests/scripts/test034-translucent +++ b/tests/scripts/test034-translucent @@ -755,6 +755,14 @@ if test -z "$ATTR" ; then exit 1 fi +$LDAPSEARCH -H $URI2 -b "o=translucent" "(employeeType=consult*)" > $SEARCHOUT 2>&1 +ATTR=`grep dn: $SEARCHOUT` > $NOWHERE 2>&1 +if test -z "$ATTR" ; then + echo "got no result, should have found entry" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + echo "Testing search: unconfigured remote filter..." $LDAPSEARCH -H $URI2 -b "o=translucent" "(|(employeeType=foo)(carlicense=right))" > $SEARCHOUT 2>&1 -- 2.47.2