aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2013-08-02 15:24:45 -0700
committerRobert Greenwalt <rgreenwalt@google.com>2013-08-05 18:44:30 +0000
commit1d8d9a308c5afa6de8dfe78f3fb8ad88b373675d (patch)
tree294eb08785d9d8cecf211217c56c06d6fe928055
parent3287dccf2ecced89bb39b857abc8eba997bc3f51 (diff)
downloadandroid_bionic-1d8d9a308c5afa6de8dfe78f3fb8ad88b373675d.tar.gz
android_bionic-1d8d9a308c5afa6de8dfe78f3fb8ad88b373675d.tar.bz2
android_bionic-1d8d9a308c5afa6de8dfe78f3fb8ad88b373675d.zip
Fix the detection of alt-network in dns resolver.
Used to determine proper A/AAAA record request. bug:10132565 Change-Id: I7229f6672e879920a6fae58672cddd72db78546c
-rw-r--r--libc/netbsd/net/getaddrinfo.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/libc/netbsd/net/getaddrinfo.c b/libc/netbsd/net/getaddrinfo.c
index 9379c53eb..c4766e406 100644
--- a/libc/netbsd/net/getaddrinfo.c
+++ b/libc/netbsd/net/getaddrinfo.c
@@ -93,6 +93,7 @@
#include <errno.h>
#include <netdb.h>
#include "resolv_private.h"
+#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@@ -1864,17 +1865,19 @@ error:
free(elems);
}
-static int _using_alt_dns()
+static bool _using_default_dns(const char *iface)
{
- char propname[PROP_NAME_MAX];
- char propvalue[PROP_VALUE_MAX];
+ char buf[IF_NAMESIZE+1];
+ size_t if_len;
- propvalue[0] = 0;
- snprintf(propname, sizeof(propname), "net.dns1.%d", getpid());
- if (__system_property_get(propname, propvalue) > 0 ) {
- return 1;
+ // common case
+ if (iface == NULL || *iface == '\0') return true;
+
+ if_len = _resolv_get_default_iface(buf, sizeof(buf));
+ if (if_len + 1 <= sizeof(buf)) {
+ if (strcmp(buf, iface) != 0) return false;
}
- return 0;
+ return true;
}
/*ARGSUSED*/
@@ -1924,7 +1927,7 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
// Only implement AI_ADDRCONFIG if the application is not
// using its own DNS servers, since our implementation
// only works on the default connection.
- if (!_using_alt_dns()) {
+ if (_using_default_dns(iface)) {
query_ipv6 = _have_ipv6();
query_ipv4 = _have_ipv4();
}