From 525750e1356a21f55cc3bb50e802b0a13b58daa5 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Wed, 30 Jul 2025 15:10:27 +0200 Subject: [PATCH] BUG/MINOR: cfgparse: immediately stop after hard error in srv_init() Since 368d01361 (" MEDIUM: server: add and use srv_init() function"), in case of srv_init() error, we simply increment cfgerr variable and keep going. It isn't enough, some treatment occuring later in check_config_validity() assume that srv_init() succeeded for servers, and may cause undefined behavior. To fix the issue, let's consider that if (srv_init() & ERR_CODE) returns true, then we must stop checking the config immediately. No backport needed unless 368d01361 is. --- src/cfgparse.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cfgparse.c b/src/cfgparse.c index 50267f261..040e35549 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2824,10 +2824,9 @@ int check_config_validity() * as some of the fields may be accessed soon */ MT_LIST_FOR_EACH_ENTRY_LOCKED(newsrv, &servers_list, global_list, back) { - if (srv_init(newsrv) & ERR_CODE) { - cfgerr++; - continue; - } + err_code |= srv_init(newsrv); + if (err_code & ERR_CODE) + goto out; } /* starting to initialize the main proxies list */