BUG/MEDIUM: tools: do not force an unresolved address to AF_INET:0.0.0.0

This prevents DNS from resolving IPv6-only servers in 1.7. Note, this
patch depends on the previous series :

  1. BUG/MINOR: tools: fix off-by-one in port size check
  2. BUG/MEDIUM: server: consider AF_UNSPEC as a valid address family
  3. MEDIUM: server: split the address and the port into two different fields
  4. MINOR: tools: make str2sa_range() return the port in a separate argument
  5. MINOR: server: take the destination port from the port field, not the addr
  6. MEDIUM: server: disable protocol validations when the server doesn't resolve

This fix (hence the whole series) must be backported to 1.7.
This commit is contained in:
Willy Tarreau 2017-01-06 19:23:20 +01:00
parent 9698f4b295
commit 7b760c9c80

View File

@ -958,14 +958,7 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
* set or if resolve is set, otherwise it's an error.
*/
if (str2ip2(str2, &ss, 0) == NULL) {
if (!resolve && fqdn) {
/* we'll still want to store the port, so let's
* force it to IPv4 for now.
*/
memset(&ss, 0, sizeof(ss));
ss.ss_family = AF_INET;
}
else if ((!resolve && !fqdn) ||
if ((!resolve && !fqdn) ||
(resolve && str2ip2(str2, &ss, 1) == NULL)) {
memprintf(err, "invalid address: '%s' in '%s'\n", str2, str);
goto out;