]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: pattern: do not index too large prefixes using the tree
authorWilly Tarreau <w@1wt.eu>
Tue, 1 Dec 2026 13:25:01 +0000 (14:25 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 1 Dec 2026 13:27:32 +0000 (14:27 +0100)
This is exactly the same as commit 60904f86 ("BUG/MINOR: pattern: do
not index too large strings using the tree") but for pat_idx_tree_pfx()
this time: we need to limit the length of indexed prefixes with trees
to 4095 bytes, the other ones need to use the list.

This needs to be backported to all versions.

src/pattern.c

index 00042417837c50d3807d109d8580cd5722c9ef67..4fce6f2cd66d4fef7d8a60e3b797063e047d0605 100644 (file)
@@ -1474,6 +1474,12 @@ int pat_idx_tree_pfx(struct pattern_expr *expr, struct pattern *pat, char **err)
        /* Process the key len */
        len = pat->len;
 
+       /* If the string is longer than what ebtrees may index (32767 bits) we
+        * cannot use trees.
+        */
+       if (len >= 4095)
+               return pat_idx_list_str(expr, pat, err);
+
        /* node memory allocation */
        node = calloc(1, sizeof(*node) + len + 1);
        if (!node) {