Honor valid DNS result even if other class returned an error

When using ares_getaddrinfo() with PF_UNSPEC, if a DNS server returned
good data on an A record, followed by bad data on an AAAA record, the
good record would be thrown away and an error returned.

If we got a good response from one of the two queries, regardless of
the order returned, we should honor that.

Fix By: Dmitry Karpov (dkarpov@roku.com)
Signed Off By: Brad House (@bradh352)
pull/465/head
bradh352 3 years ago
parent 77adcc5e51
commit 7eb399a83c
  1. 11
      src/lib/ares_getaddrinfo.c

@ -550,7 +550,16 @@ static void host_callback(void *arg, int status, int timeouts,
if (addinfostatus != ARES_SUCCESS && addinfostatus != ARES_ENODATA)
{
/* error in parsing result e.g. no memory */
end_hquery(hquery, addinfostatus);
if (addinfostatus == ARES_EBADRESP && hquery->ai->nodes)
{
/* We got a bad response from server, but at least one query
* ended with ARES_SUCCESS */
end_hquery(hquery, ARES_SUCCESS);
}
else
{
end_hquery(hquery, addinfostatus);
}
}
else if (hquery->ai->nodes)
{

Loading…
Cancel
Save