]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9825 dynlist: don't lose earlier filter elements
authorHoward Chu <hyc@openldap.org>
Thu, 21 Apr 2022 14:40:14 +0000 (15:40 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 27 Apr 2022 15:43:02 +0000 (15:43 +0000)
servers/slapd/overlays/dynlist.c

index b04f65c0c6eaacd7fb04afead9517b83f6919f69..3490cfb640e3b3e50f0a4a13a8865d24ea0866c2 100644 (file)
@@ -1208,13 +1208,16 @@ dynlist_filter_stgroup( Operation *op, Filter *n, Attribute *a )
        Filter *dnf, *orf = NULL;
        int i;
 
-       if ( a->a_numvals == 1 ) {
+       if ( a->a_numvals == 1 && n->f_choice == SLAPD_FILTER_COMPUTED ) {
                dnf = n;
        } else {
                orf = n;
-               orf->f_choice = LDAP_FILTER_OR;
+               if ( n->f_choice != LDAP_FILTER_OR ) {
+                       orf->f_choice = LDAP_FILTER_OR;
+                       orf->f_list = NULL;
+               }
                dnf = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx );
-               dnf->f_next = NULL;
+               dnf->f_next = orf->f_list;
                orf->f_list = dnf;
        }
 
@@ -1298,9 +1301,9 @@ dynlist_filter_dup( Operation *op, Filter *f, AttributeDescription *ad, dynlist_
                break;
 
        case LDAP_FILTER_EQUALITY:
-               n->f_choice = SLAPD_FILTER_COMPUTED;
                if ( f->f_av_desc == ad ) {
                        dynlist_name_t *dyn = ldap_tavl_find( ds->ds_names, &f->f_av_value, dynlist_avl_cmp );
+                       n->f_choice = SLAPD_FILTER_COMPUTED;
                        if ( dyn && !dynlist_filter_group( op, dyn, n, ds ))
                                break;
                }