]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: dns: gracefully handle the "udp@" address format for nameservers
authorWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 18:04:17 +0000 (20:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 18:11:52 +0000 (20:11 +0200)
Just like with previous commit, DNS nameservers are affected as well with
addresses starting in "udp@", but here it's different, because due to
another bug in the DNS parser, the address is rejected, indicating that
it doesn't have a ->connect() method. Similarly, the DNS code believes
it's working on top of TCP at this point and this used to work because of
this. The same fix is applied to remap the protocol and the ->connect test
was dropped.

No backport is needed, as the ->connect() test will never strike in 2.2
or below.

src/cfgparse.c

index 7fc499a6fe3093f9b990957f6bbb5fed34272eea..c5b2b20dd4e69ee0f20a8cef20240dd70a969f1d 100644 (file)
@@ -1041,8 +1041,14 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
 
+               /* handle nicely the case where "udp@" is forced */
+               if (sk->ss_family == AF_CUST_UDP4)
+                       sk->ss_family = AF_INET;
+               else if (sk->ss_family == AF_CUST_UDP6)
+                       sk->ss_family = AF_INET6;
+
                proto = protocol_by_family(sk->ss_family);
-               if (!proto || !proto->connect) {
+               if (!proto) {
                        ha_alert("parsing [%s:%d] : '%s %s' : connect() not supported for this address family.\n",
                                file, linenum, args[0], args[1]);
                        err_code |= ERR_ALERT | ERR_FATAL;