]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: pattern: consider gen_id in pat_ref_set_from_node()
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 20 Nov 2024 16:26:23 +0000 (17:26 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 26 Nov 2024 15:12:26 +0000 (16:12 +0100)
Don't set all duplicates from a given node if they don't have the same
gen_id. Indeed, now we consider the gen_id to only work on the same
pattern ref revision.

src/pattern.c

index c433c10b202c217d933c2c299b67f1b814482c5c..e342db10bb20f4e707c3b9f562489fcc0d23a301 100644 (file)
@@ -1805,12 +1805,20 @@ int pat_ref_set_by_id(struct pat_ref *ref, struct pat_ref_elt *refelt, const cha
 static int pat_ref_set_from_node(struct pat_ref *ref, struct ebmb_node *node, const char *value, char **err)
 {
        struct pat_ref_elt *elt;
+       unsigned int gen;
+       int first = 1;
        int found = 0;
 
        while (node) {
                char *tmp_err = NULL;
 
                elt = ebmb_entry(node, struct pat_ref_elt, node);
+               if (first)
+                       gen = elt->gen_id;
+               else if (elt->gen_id != gen) {
+                       /* only consider duplicate elements from the same gen! */
+                       continue;
+               }
                node = ebmb_next_dup(node);
                if (!pat_ref_set_elt(ref, elt, value, &tmp_err)) {
                        if (err)
@@ -1820,6 +1828,7 @@ static int pat_ref_set_from_node(struct pat_ref *ref, struct ebmb_node *node, co
                        return 0;
                }
                found = 1;
+               first = 0;
        }
 
        if (!found) {