summaryrefslogtreecommitdiff
path: root/ares_gethostbyname.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-06-13 12:53:22 +0200
committerJakub Hrozek <jhrozek@redhat.com>2011-06-14 16:41:29 +0200
commitb5823d65706af687c0e5110af8f0cfdcd068997d (patch)
treeabcfbb582536a5d3b818181f521e6cae460cac90 /ares_gethostbyname.c
parent22c01e96f7b2ae9923e1baa50bfe3c0d22297a7d (diff)
downloadc-ares-b5823d65706af687c0e5110af8f0cfdcd068997d.tar.gz
c-ares-b5823d65706af687c0e5110af8f0cfdcd068997d.tar.bz2
c-ares-b5823d65706af687c0e5110af8f0cfdcd068997d.zip
Only fall back to AF_INET searches when looking for AF_UNSPEC addresses
Diffstat (limited to 'ares_gethostbyname.c')
-rw-r--r--ares_gethostbyname.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c
index 72f8f8b..ad89dc2 100644
--- a/ares_gethostbyname.c
+++ b/ares_gethostbyname.c
@@ -194,11 +194,11 @@ static void host_callback(void *arg, int status, int timeouts,
else if (hquery->sent_family == AF_INET6)
{
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
- if (status == ARES_ENODATA || status == ARES_EBADRESP) {
+ if ((status == ARES_ENODATA || status == ARES_EBADRESP) &&
+ hquery->want_family == AF_UNSPEC) {
/* The query returned something but either there were no AAAA
records (e.g. just CNAME) or the response was malformed. Try
- looking up A instead. We should possibly limit this
- attempt-next logic to AF_UNSPEC lookups only. */
+ looking up A instead. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A,
host_callback, hquery);
@@ -210,11 +210,10 @@ static void host_callback(void *arg, int status, int timeouts,
end_hquery(hquery, status, host);
}
else if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
- status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
+ status == ARES_ETIMEOUT) && (hquery->sent_family == AF_INET6 &&
+ hquery->want_family == AF_UNSPEC))
{
- /* The AAAA query yielded no useful result. Now look up an A instead.
- We should possibly limit this attempt-next logic to AF_UNSPEC lookups
- only. */
+ /* The AAAA query yielded no useful result. Now look up an A instead. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
hquery);