summaryrefslogtreecommitdiff
path: root/ares_gethostbyname.c
diff options
context:
space:
mode:
authorPhil Blundell <pb@reciva.com>2009-02-03 14:38:09 +0000
committerPhil Blundell <pb@reciva.com>2009-02-03 14:38:09 +0000
commit3f7fc80ab5acb16f5e709d8f2cf8a12c934715aa (patch)
tree67a7813a5dade2bc8411fbda0e4f5b27e8776332 /ares_gethostbyname.c
parent1ce8e6583ebcdc448c3187d186a9ef219218bfdb (diff)
downloadc-ares-3f7fc80ab5acb16f5e709d8f2cf8a12c934715aa.tar.gz
c-ares-3f7fc80ab5acb16f5e709d8f2cf8a12c934715aa.tar.bz2
c-ares-3f7fc80ab5acb16f5e709d8f2cf8a12c934715aa.zip
* February 3 2009 (Phil Blundell)
- If the server returns garbage or nothing at all in response to an AAAA query, go on and ask for A records anyway.
Diffstat (limited to 'ares_gethostbyname.c')
-rw-r--r--ares_gethostbyname.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c
index e6b9f7f..61fc592 100644
--- a/ares_gethostbyname.c
+++ b/ares_gethostbyname.c
@@ -194,10 +194,10 @@ 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) {
- /* The query returned something (e.g. CNAME) but there were no
- AAAA records. Try looking up A instead. We should possibly
- limit this attempt-next logic to AF_UNSPEC lookups only. */
+ if (status == ARES_ENODATA || status == ARES_EBADRESP) {
+ /* 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. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A,
host_callback, hquery);
@@ -208,10 +208,10 @@ static void host_callback(void *arg, int status, int timeouts,
}
end_hquery(hquery, status, host);
}
- else if (status == ARES_ENODATA && hquery->sent_family == AF_INET6)
+ else if ((status == ARES_ENODATA || status == ARES_EBADRESP || status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
{
- /* There was no AAAA. Now lookup an A. 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.
+ We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
hquery);