diff options
Diffstat (limited to 'libc/netbsd')
| -rw-r--r-- | libc/netbsd/net/getaddrinfo.c | 8 | ||||
| -rw-r--r-- | libc/netbsd/net/getservent.c | 9 | ||||
| -rw-r--r-- | libc/netbsd/resolv/res_comp.c | 9 | ||||
| -rw-r--r-- | libc/netbsd/resolv/res_init.c | 37 |
4 files changed, 58 insertions, 5 deletions
diff --git a/libc/netbsd/net/getaddrinfo.c b/libc/netbsd/net/getaddrinfo.c index 2dd3d97..f2189fb 100644 --- a/libc/netbsd/net/getaddrinfo.c +++ b/libc/netbsd/net/getaddrinfo.c @@ -912,7 +912,11 @@ get_port(const struct addrinfo *ai, const char *servname, int matchonly) allownumeric = 1; break; case ANY: +#if 1 /* ANDROID-SPECIFIC CHANGE TO MATCH GLIBC */ + allownumeric = 1; +#else allownumeric = 0; +#endif break; default: return EAI_SOCKTYPE; @@ -1271,7 +1275,7 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap) name = va_arg(ap, char *); pai = va_arg(ap, const struct addrinfo *); - fprintf(stderr, "_dns_getaddrinfo() name = '%s'\n", name); + //fprintf(stderr, "_dns_getaddrinfo() name = '%s'\n", name); memset(&q, 0, sizeof(q)); memset(&q2, 0, sizeof(q2)); @@ -1630,7 +1634,7 @@ res_searchN(const char *name, struct res_target *target, res_state res) trailing_dot++; -fprintf(stderr, "res_searchN() name = '%s'\n", name); + //fprintf(stderr, "res_searchN() name = '%s'\n", name); /* * if there aren't any dots, it could be a user-level alias diff --git a/libc/netbsd/net/getservent.c b/libc/netbsd/net/getservent.c index 45207df..9f6ec32 100644 --- a/libc/netbsd/net/getservent.c +++ b/libc/netbsd/net/getservent.c @@ -27,6 +27,7 @@ */ #include <sys/cdefs.h> #include <sys/types.h> +#include <endian.h> #include <netdb.h> #include "servent.h" #include "services.h" @@ -54,6 +55,7 @@ getservent_r( res_static rs ) int namelen; int nn,count; int total = 0; + int port; char* p2; p = rs->servent_ptr; @@ -92,9 +94,12 @@ getservent_r( res_static rs ) memcpy( rs->servent.s_name, p+1, namelen ); rs->servent.s_name[namelen] = 0; p += 1 + namelen; - rs->servent.s_port = ((((unsigned char*)p)[0] << 8) | - ((unsigned char*)p)[1]); + /* s_port must be in network byte order */ + port = ((((unsigned char*)p)[0] << 8) | + ((unsigned char*)p)[1]); + + rs->servent.s_port = htons(port); rs->servent.s_proto = p[2] == 't' ? "tcp" : "udp"; p += 4; /* skip port(2) + proto(1) + aliascount(1) */ diff --git a/libc/netbsd/resolv/res_comp.c b/libc/netbsd/resolv/res_comp.c index 6991e8b..77b81b4 100644 --- a/libc/netbsd/resolv/res_comp.c +++ b/libc/netbsd/resolv/res_comp.c @@ -147,6 +147,12 @@ dn_skipname(const u_char *ptr, const u_char *eom) { * tell us anything about network-format data. The rest of the BIND system * is not careful about this, but for some reason, we're doing it right here. */ + +/* BIONIC: We also accept underscores in the middle of labels. + * This extension is needed to make resolution on some VPN networks + * work properly. + */ + #define PERIOD 0x2e #define hyphenchar(c) ((c) == 0x2d) #define bslashchar(c) ((c) == 0x5c) @@ -155,9 +161,10 @@ dn_skipname(const u_char *ptr, const u_char *eom) { #define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \ || ((c) >= 0x61 && (c) <= 0x7a)) #define digitchar(c) ((c) >= 0x30 && (c) <= 0x39) +#define underscorechar(c) ((c) == 0x5f) #define borderchar(c) (alphachar(c) || digitchar(c)) -#define middlechar(c) (borderchar(c) || hyphenchar(c)) +#define middlechar(c) (borderchar(c) || hyphenchar(c) || underscorechar(c)) #define domainchar(c) ((c) > 0x20 && (c) < 0x7f) int diff --git a/libc/netbsd/resolv/res_init.c b/libc/netbsd/resolv/res_init.c index fc0272c..751603d 100644 --- a/libc/netbsd/resolv/res_init.c +++ b/libc/netbsd/resolv/res_init.c @@ -112,6 +112,7 @@ __RCSID("$NetBSD: res_init.c,v 1.8 2006/03/19 03:10:08 christos Exp $"); #define MAX_DNS_PROPERTIES 8 #define DNS_PROP_NAME_PREFIX "net.dns" #define DNS_CHANGE_PROP_NAME "net.dnschange" +#define DNS_SEARCH_PROP_NAME "net.dns.search" const prop_info *dns_change_prop; int dns_last_change_counter; static int _get_dns_change_count(); @@ -168,6 +169,39 @@ res_ninit(res_state statp) { return (__res_vinit(statp, 0)); } +#ifdef ANDROID_CHANGES +int load_domain_search_list(res_state statp) { + char propvalue[PROP_VALUE_MAX]; + register char *cp, **pp; + + if(__system_property_get(DNS_SEARCH_PROP_NAME, propvalue) >= 1) { + strlcpy(statp->defdname, propvalue, sizeof(statp->defdname)); + if ((cp = strchr(statp->defdname, '\n')) != NULL) + *cp = '\0'; + cp = statp->defdname; + pp = statp->dnsrch; + while ( pp < statp->dnsrch + MAXDNSRCH ) { + while (*cp == ' ' || *cp == '\t') /* skip leading white space */ + cp++; + if (*cp == '\0') /* stop if nothing more */ + break; + *pp++ = cp; /* record this search domain */ + while (*cp) { /* zero-terminate it */ + if (*cp == ' ' || *cp == '\t') { + *cp++ = '\0'; + break; + } + cp++; + } + } + *pp = NULL; /* statp->dnsrch has MAXDNSRCH+1 items */ + if (pp > statp->dnsrch) + return 1; + } + return 0; +} +#endif + /* This function has to be reachable by res_data.c but not publicly. */ int __res_vinit(res_state statp, int preinit) { @@ -344,6 +378,9 @@ __res_vinit(res_state statp, int preinit) { } } } + + /* Add the domain search list */ + havesearch = load_domain_search_list(statp); #else /* IGNORE resolv.conf */ #define MATCH(line, name) \ (!strncmp(line, name, sizeof(name) - 1) && \ |
