]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: sample: set SMP_F_CONST on srv_name fetch
authorAlexander Stephan <alexander.stephan@sap.com>
Thu, 25 Jun 2026 09:02:06 +0000 (09:02 +0000)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 1 Jul 2026 07:11:18 +0000 (09:11 +0200)
commit9475e69920f04174496caf71fcabf6e72824f5c2
tree1f523351ed2127fc04ed445029bed0b1bb1acc53
parent7aec1e6d9ab2ccc11ce3c66610a8117cda2be094
BUG/MINOR: sample: set SMP_F_CONST on srv_name fetch

smp_fetch_srv_name() stored a raw pointer to srv->id in the sample
without setting SMP_F_CONST. Every other sibling id-pointer fetch
(smp_fetch_be_name on px->id, smp_fetch_fe_name on fe->id, the SSL
helpers using OBJ_nid2sn() / SSL_get_cipher_name(), etc.) correctly
sets SMP_F_CONST to prevent in-place mutation by converters such as
,upper / ,lower / ,regsub.

Without SMP_F_CONST, an expression like srv_name,lower would write
into srv->id for the lifetime of the process. In practice this has
gone unnoticed because srv->id is a private allocation that is never
read back by name, but the bug is real and the divergence from the
other id fetches is unintentional.

This becomes more important with the introduction of runtime server
renaming (next patch in series): SMP_F_CONST ensures that callers go
through smp_make_rw() / smp_dup() before mutating, isolating the
sample's bytes from the server's id storage.

This is a stand-alone fix and should be backported.
src/backend.c