]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10280 dynlist: fix filters that reuse the same term multiple times
authorHoward Chu <hyc@openldap.org>
Mon, 13 Apr 2026 14:32:04 +0000 (15:32 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 28 Apr 2026 18:42:35 +0000 (18:42 +0000)
Use SLAPD_FILTER_REUSED for redundant filter terms

servers/slapd/overlays/dynlist.c

index d12340d4c5eb28d4b11909b705156f9c6331f9d8..16672dae36a351ddcfd8832aaee134ca272406bf 100644 (file)
@@ -452,6 +452,8 @@ typedef struct dynlist_name_t {
        dynlist_info_t *dy_dli;
        dynlist_map_t *dy_dlm;
        AttributeDescription *dy_staticmember;
+       Filter *dy_filter;
+       int dy_filter_reused;
        int dy_seen;
        int dy_numuris;
        TAvlnode *dy_subs;
@@ -1382,8 +1384,21 @@ dynlist_filter_group( Operation *op, dynlist_name_t *dyn, Filter *n, dynlist_sea
        Attribute *a;
        int rc = -1;
 
-       if ( ldap_tavl_insert( &ds->ds_fnodes, dyn, dynlist_ptr_cmp, ldap_avl_dup_error ))
+       if ( ldap_tavl_insert( &ds->ds_fnodes, dyn, dynlist_ptr_cmp, ldap_avl_dup_error )) {
+               if ( !dyn->dy_filter_reused ) {
+                       Filter *nf = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx );
+                       nf->f_choice = dyn->dy_filter->f_choice;
+                       nf->f_list = dyn->dy_filter->f_list;
+                       nf->f_next = NULL;
+                       dyn->dy_filter->f_choice = LDAP_FILTER_OR;
+                       dyn->dy_filter->f_list = nf;
+                       dyn->dy_filter_reused = 1;
+               }
+               n->f_choice = LDAP_FILTER_OR | SLAPD_FILTER_REUSED;
+               n->f_list = dyn->dy_filter->f_list;
                return 0;
+       }
+       dyn->dy_filter = n;
 
        if ( overlay_entry_get_ov( op, &dyn->dy_nname, NULL, NULL, 0, &e, on ) !=
                LDAP_SUCCESS || e == NULL ) {