BUG/MINOR: init: Use a dynamic buffer to set HAPROXY_CFGFILES env variable
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 12 Jan 2021 17:57:38 +0000 (18:57 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 26 Jan 2021 09:05:22 +0000 (10:05 +0100)
commit33edd5101136f9e0a7fecb07e1fb7a32d5c1e9e8
treee9d63b13c39e945cbac9abd8e2821f53f5b9538e
parent10189c965bc2f4b397608855c437fdb01e29f73a
BUG/MINOR: init: Use a dynamic buffer to set HAPROXY_CFGFILES env variable

The HAPROXY_CFGFILES env variable is built using a static trash chunk, via a
call to get_trash_chunk() function. This chunk is reserved during the whole
configuration parsing. It is far too large to guarantee it will not be
reused during the configuration parsing. And in fact, it happens in the lua
code since the commit f67442efd ("BUG/MINOR: lua: warn when registering
action, conv, sf, cli or applet multiple times"), when a lua script is
loaded.

To fix the bug, we now use a dynamic buffer instead. And we call memprintf()
function to handle both the allocation and the formatting. Allocation errors
at this stage are fatal.

This patch should fix the issue #1041. It must be backported as far as 2.0.

(cherry picked from commit 4e36682d51f4e206c63d792a8cde3e669fb8a0d4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/haproxy.c