]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: peers: fix segfault using multiple bind on peers sections
authorEmeric Brun <ebrun@haproxy.com>
Wed, 25 May 2022 08:12:07 +0000 (10:12 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 25 May 2022 13:10:08 +0000 (15:10 +0200)
commit49f6f4b1a7895b8906c2ee5a183f013db00fcaf0
tree5433cad3b11e1b9f0cfb15dddc50c77fd2416aa6
parent4315d17d3fbcfd1074ff05fed1eec01d0fc89805
BUG/MEDIUM: peers: fix segfault using multiple bind on peers sections

If multiple "bind" lines were present on the "peers" section, multiple
listeners were added to a list but the code mistakenly initialize
the first member and this first listener was re-configured instead of
the newly created one. The last one remains uninitialized causing a null
dereference a soon a connection is received.

In addition, the 'peers' sections and protocol are not currently designed to
handle multiple listeners.

This patch check if there is already a listener configured on the 'peers'
section when we want to create a new one. This is rising an error if
a listener is already present showing the file and line in the error
message.

To keep the file and line number of the previous listener available
for the error message, the 'bind_conf_uniq_alloc' function was modified
to keep the file/line data the struct 'bind_conf' was firstly
allocated (previously it was updated each time the 'bind_conf' was
reused).

This patch should be backported until version 2.0
src/cfgparse.c