summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2013-08-22 16:56:48 -0700
committerRobert Greenwalt <rgreenwalt@google.com>2013-08-22 21:05:49 -0700
commita31ddef36df7970db1145f7ae66060f8e3eebf3f (patch)
treebcdbe18c8f83df14995512955341223acdce4c23 /libc
parent41f08abf3d020ad8b48ff4151f8c623a119790e0 (diff)
downloadbionic-a31ddef36df7970db1145f7ae66060f8e3eebf3f.zip
bionic-a31ddef36df7970db1145f7ae66060f8e3eebf3f.tar.gz
bionic-a31ddef36df7970db1145f7ae66060f8e3eebf3f.tar.bz2
Change how DNS resolver handle no default iface
We used to just try any iface we'd been told about as a fallback, but that will end up mistakenly using a secondary network's dns when we really don't have a default connection. It also messed up our detection of whether we were doing the lookup on the default or not (we'd get back our secondary net iface as the default, do the compare and think we were on default). Remove the lies and let dns fail if we don't have an iface for it. bug:10132565 Change-Id: I5f0f2abacaaaaf23c5292b20fba9d8dcb6fb10c5
Diffstat (limited to 'libc')
-rw-r--r--libc/netbsd/net/getaddrinfo.c6
-rw-r--r--libc/netbsd/resolv/res_cache.c16
2 files changed, 10 insertions, 12 deletions
diff --git a/libc/netbsd/net/getaddrinfo.c b/libc/netbsd/net/getaddrinfo.c
index c4766e4..0d1949d 100644
--- a/libc/netbsd/net/getaddrinfo.c
+++ b/libc/netbsd/net/getaddrinfo.c
@@ -1874,10 +1874,10 @@ static bool _using_default_dns(const char *iface)
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;
+ if (if_len != 0 && if_len + 1 <= sizeof(buf)) {
+ if (strcmp(buf, iface) == 0) return true;
}
- return true;
+ return false;
}
/*ARGSUSED*/
diff --git a/libc/netbsd/resolv/res_cache.c b/libc/netbsd/resolv/res_cache.c
index 829bf10..7e367ad 100644
--- a/libc/netbsd/resolv/res_cache.c
+++ b/libc/netbsd/resolv/res_cache.c
@@ -2426,18 +2426,16 @@ _resolv_get_default_iface(char* buff, int buffLen)
ifname = _get_default_iface_locked(); // never null, but may be empty
- // if default interface not set. Get first cache with an interface
+ // if default interface not set give up.
if (ifname[0] == '\0') {
- ifname = _find_any_iface_name_locked(); // may be null
+ pthread_mutex_unlock(&_res_cache_list_lock);
+ return 0;
}
- // if we got the default iface or if (no-default) the find_any call gave an answer
- if (ifname) {
- len = strlen(ifname);
- if (len < buffLen) {
- strncpy(buff, ifname, len);
- buff[len] = '\0';
- }
+ len = strlen(ifname);
+ if (len < buffLen) {
+ strncpy(buff, ifname, len);
+ buff[len] = '\0';
} else {
buff[0] = '\0';
}