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

(cherry picked from commit 49f6f4b1a7895b8906c2ee5a183f013db00fcaf0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 411689dfd8e04716220eebe441fa4b836fb0a6b1)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
1 file changed