]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cfgparse-listen: update err_code for fatal error on proxy directive
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 7 Aug 2025 10:45:58 +0000 (12:45 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 7 Aug 2025 20:26:42 +0000 (22:26 +0200)
When improper arguments are provided on proxy directive (listen,
frontend or backend), such alert may be emitted:

  "please use the 'bind' keyword for listening addresses"

This was introduced in 6e62fb6405 ("MEDIUM: cfgparse: check section
maximum number of arguments"). However, despite the error being reported
as alert, the err_code isn't updated accordingly, which could make the
upper parser think there was no error, while it isn't the case.

In practise since the proxy directive is ignored following proxy related
directives should raise errors, so this didn't cause much harm, yet
better fix that.

It could be backported to all stable versions.

src/cfgparse-listen.c

index bcc36c938b790ffdcfe2f65488399fb23d31f694..07bb050122770b5821917612ac513577be171663 100644 (file)
@@ -367,8 +367,10 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
 
                if ((*args[2] && (!*args[3] || strcmp(args[2], "from") != 0)) ||
                    alertif_too_many_args(3, file, linenum, args, &err_code)) {
-                       if (rc & PR_CAP_FE)
+                       if (rc & PR_CAP_FE) {
+                               err_code |= ERR_ALERT | ERR_FATAL;
                                ha_alert("parsing [%s:%d] : please use the 'bind' keyword for listening addresses.\n", file, linenum);
+                       }
                        goto out;
                }
        }