From: Willy Tarreau Date: Tue, 1 Dec 2026 13:25:01 +0000 (+0100) Subject: BUG/MINOR: pattern: do not index too large prefixes using the tree X-Git-Url: https://git.kaiwu.me/web/%7B@url%7D?a=commitdiff_plain;h=78ae671a0a89b3ee226c27398315796a505b5dc3;p=haproxy.git BUG/MINOR: pattern: do not index too large prefixes using the tree 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. --- diff --git a/src/pattern.c b/src/pattern.c index 000424178..4fce6f2cd 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -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) {