BUG/MINOR: stream: Avoid recursive evaluation for unique-id based on itself
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 23 Jun 2025 05:33:06 +0000 (07:33 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 1 Oct 2025 13:32:32 +0000 (15:32 +0200)
commit4b1177ab67d8d94c32e3155da4e9d7f3fd6d8587
tree1998d600f1ae02b0edfaf2eaf358751cdb73a43b
parent27a65a88437afa8f3bf8d754f98bf6d35f8f6b55
BUG/MINOR: stream: Avoid recursive evaluation for unique-id based on itself

There is nothing that prevent a "unique-id-format" to reference itself,
using '%ID' or '%[unique-id]'. If the sample fetch function is used, it
leads to an infinite loop, calling recursively the function responsible to
generate the unique ID.

One solution is to detect it during the configuration parsing to trigger an
error. With this patch, we just inhibit recursive calls by considering the
unique-id as empty during its evaluation. So "id-%[unique-id]" lf string
will be evaluated as "id-".

This patch must be backported to all stable versions.

(cherry picked from commit fb7b5c8a53cb4f19a223abd20660d47162aa8708)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit dfbb00ac1410af65d2befe3e94afb6cfc137b220)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit b9968b4d131918075c00708fd6ad5b51fc3146c5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/stream.c