]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cfgparse: immediately stop after hard error in srv_init()
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 30 Jul 2025 13:10:27 +0000 (15:10 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 7 Aug 2025 20:26:37 +0000 (22:26 +0200)
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

index 50267f261f04819d9a411a26a9cd5e5a0e2596de..040e3554990f2ea0499db6452222f0ca0ea66c29 100644 (file)
@@ -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 */