From: Willy Tarreau Date: Wed, 16 Sep 2020 18:04:17 +0000 (+0200) Subject: BUG/MINOR: dns: gracefully handle the "udp@" address format for nameservers X-Git-Tag: v2.3-dev5~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e42d87f3de4c5310e65f52a60e825a8349bf7d8c;p=thirdparty%2Fhaproxy.git BUG/MINOR: dns: gracefully handle the "udp@" address format for nameservers 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. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 7fc499a6fe..c5b2b20dd4 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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;