]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: peers: Peer addresses parsing broken.
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 31 Jan 2019 05:48:16 +0000 (06:48 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 31 Jan 2019 08:56:39 +0000 (09:56 +0100)
This bug was introduced by 355b203 commit which prevented the peer
addresses to be parsed for the local peer of a "peers" section.
When adding "parse_addr" boolean parameter to parse_server(), this commit
missed the case where the syntax with "peer" keyword should still be
supported in addition to the new syntax with "server"+"bind" keyword.

May be backported as fas as 1.5.

src/cfgparse.c

index 50f43cde59a3ed880d8317d5e90dc6d6c9ad3cdb..5c292f82d2bdbc917fed4742136aa1e13056d513 100644 (file)
@@ -761,8 +761,9 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
        }
        else if (strcmp(args[0], "peer") == 0 ||
                 strcmp(args[0], "server") == 0) { /* peer or server definition */
-               int local_peer;
+               int local_peer, peer;
 
+               peer = *args[0] == 'p';
                local_peer = !strcmp(args[1], localpeer);
                /* The local peer may have already partially been parsed on a "bind" line. */
                if (*args[0] == 'p') {
@@ -805,7 +806,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                }
 
                /* This initializes curpeer->peers->peers_fe->srv. */
-               err_code |= parse_server(file, linenum, args, curpeers->peers_fe, NULL, !local_peer);
+               err_code |= parse_server(file, linenum, args, curpeers->peers_fe, NULL, peer || !local_peer);
                if (!curpeers->peers_fe->srv)
                        goto out;