From: Aurelien DARRAGON Date: Thu, 8 Oct 2026 18:04:31 +0000 (+0200) Subject: BUG/MINOR: cfgparse/peers: warn and prevent undefined behavior when peers is missing... X-Git-Tag: v3.5-dev10~98 X-Git-Url: https://git.kaiwu.me/$%7BGITURL%7D/doc/static/gitweb.js?a=commitdiff_plain;h=76602594b514cff28e385e120af6da669663f436;p=haproxy.git BUG/MINOR: cfgparse/peers: warn and prevent undefined behavior when peers is missing bind info As described in GH #3516, declaring a peers section containing the local peer server (with server syntax) without the matching 'bind' diretive causes haproxy to crash since 879c78c. However, as Amaury demonstrated, the config is invalid/incomplete: it makes no sense to declare the local peer server without the matching bind parameters. Before this patch haproxy would let the config pass and the result was that the peers proxy was created without any listeners. While it somehow didn't crash in the past (perhaps the low level code was robust enough), from a peers logic point of view it results in the peers proxy doing nothing. Instead of silently failing (and now risking crashes upon reload), let's proactively report a fatal error to the user that such config is incomplete. Many thanks to @alexandret-ik for the detailed report. It should be backported to 3.4, and may be relevant to olders versions but in this case replace the ha_alert() which ha_notice() so existing configs that used to start (despite not valid from peers point of view) don't break. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 05b225114..2097f24af 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2699,6 +2699,14 @@ init_proxies_list_stage2: stop_proxy(curpeers->peers_fe); curpeers->peers_fe = NULL; } + else if (LIST_ISEMPTY(&curpeers->peers_fe->conf.listeners)) { + ha_alert("Incomplete section 'peers %s' (missing listen/bind information for local peer named '%s').\n", + curpeers->id, localpeer); + cfgerr++; + if (curpeers->peers_fe) + stop_proxy(curpeers->peers_fe); + curpeers->peers_fe = NULL; + } else { /* Initializes the transport layer of the server part of all the peers belonging to * section if required.