BUG/MINOR: server: dont return immediately from parse_server() when skipping checks
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 7 Mar 2025 08:11:21 +0000 (09:11 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 18 Mar 2025 15:27:50 +0000 (16:27 +0100)
If parse_server() is called under peers section parser, and the address
needs to be parsed but it is missing, we directly return from the function

However since 0fc136ce5b ("REORG: server: use parsing ctx for server
parsing"), parse_server() uses parsing ctx to emit warning/errors, and
the ctx must be reset before returning from the function, yet this early
return was overlooked. Because of that, any ha_{warning,alert..} message
reported after early return from parse_server() could cause messages to
have an extra "parsing [file:line]" info.

We fix that by ensuring parse_server() doesn't return without resetting
the parsing context.

It should be backported up to 2.6

(cherry picked from commit a76b5358f0400568b641dc373cbd582875cd6aa6)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit d7e564cb81be444025f4fe72202a842718059da5)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>

src/server.c

index bee4079..44cf16f 100644 (file)
@@ -3674,7 +3674,7 @@ int parse_server(const char *file, int linenum, char **args,
        if ((parse_flags & (SRV_PARSE_IN_PEER_SECTION|SRV_PARSE_PARSE_ADDR)) ==
            (SRV_PARSE_IN_PEER_SECTION|SRV_PARSE_PARSE_ADDR)) {
                if (!*args[2])
-                       return 0;
+                       goto out;
        }
 
        err_code = _srv_parse_init(&newsrv, args, &cur_arg, curproxy,