]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: vars: fix missing string termination in get var on too long values
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 16:16:44 +0000 (17:16 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 16:28:20 +0000 (17:28 +0100)
commit1021db1d76e7e69d04819a7a320062dea1161450
treee75600bba73f2bff1b7f5939dc50379fabf0b10b
parentb4e427bda9073816767005d51f5b1ceaab73905b
BUG/MINOR: vars: fix missing string termination in get var on too long values

vars_parse_cli_get_var() builds the output for the CLI's "get var" in the
shared trash chunk using b_putchr(), which silently drops bytes once the
buffer is full. For a value long enough to exhaust trash mid-loop, the
trailing '>' and the terminating NUL were dropped, leaving trash.area
without any NUL within its bounds. cli_msg() only stores the pointer and the
string is later read with ist() (i.e. strlen) in cli_output_msg(), reading
past the buffer.

Now the loop stops before the last byte, and the terminating NUL is always
written within bounds, truncating the output if needed.

This patch should fix the issue #3592. It could be backported to all
supported versions.
src/vars.c