diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2013-08-05 11:55:53 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-08-05 11:55:53 -0700 |
commit | 662bb875e4c66874b72bff51206d881c9b6b195b (patch) | |
tree | 15bd97c12596671c1032f4df6092276cdfb64dd8 /libc/netbsd/net/getaddrinfo.c | |
parent | 49b24b4efbc95cbff6dc73007583a880f7c01e7e (diff) | |
parent | a9c5bb972df7cbb4e65cfb53673b26f9d42deacd (diff) | |
download | android_bionic-662bb875e4c66874b72bff51206d881c9b6b195b.tar.gz android_bionic-662bb875e4c66874b72bff51206d881c9b6b195b.tar.bz2 android_bionic-662bb875e4c66874b72bff51206d881c9b6b195b.zip |
am a9c5bb97: Merge "Fix the detection of alt-network in dns resolver."
* commit 'a9c5bb972df7cbb4e65cfb53673b26f9d42deacd':
Fix the detection of alt-network in dns resolver.
Diffstat (limited to 'libc/netbsd/net/getaddrinfo.c')
-rw-r--r-- | libc/netbsd/net/getaddrinfo.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/libc/netbsd/net/getaddrinfo.c b/libc/netbsd/net/getaddrinfo.c index 09da66c14..8c1a01b5d 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*/ @@ -1926,7 +1929,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(); } |