diff options
author | Brian Carlstrom <bdc@google.com> | 2011-04-29 16:43:16 -0700 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2011-09-17 02:12:39 -0700 |
commit | 25a26a0a4443278a651773426bb907c552639b47 (patch) | |
tree | a98e1dcd074c17148cf127da68d372be8ea6faf9 | |
parent | eef63faed8ff12a8c2ff91af7fcd61f77428d73a (diff) | |
download | bionic-25a26a0a4443278a651773426bb907c552639b47.zip bionic-25a26a0a4443278a651773426bb907c552639b47.tar.gz bionic-25a26a0a4443278a651773426bb907c552639b47.tar.bz2 |
Tracking change to dns proxy protocol
The gethostbyaddr code in system/netd now expects a string address
from inet_ntop, not raw bytes, in order to properly pass addresses
containing null and probably spaces and newlines characeters as well.
Bug: 4344448
Change-Id: I8ec0eab94d5b1d38e9269ba3afb2825e946f8df3
-rw-r--r-- | libc/netbsd/net/getnameinfo.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libc/netbsd/net/getnameinfo.c b/libc/netbsd/net/getnameinfo.c index 0b9fe51..d3d0011 100644 --- a/libc/netbsd/net/getnameinfo.c +++ b/libc/netbsd/net/getnameinfo.c @@ -135,7 +135,7 @@ int getnameinfo(const struct sockaddr* sa, socklen_t salen, char* host, size_t h * the address. On failure -1 is returned in which case * normal execution flow shall continue. */ static int -android_gethostbyaddr_proxy(struct hostent* hp, const char *addr, socklen_t addrLen, int addrFamily) { +android_gethostbyaddr_proxy(struct hostent* hp, const void *addr, socklen_t addrLen, int addrFamily) { int sock; const int one = 1; @@ -170,7 +170,7 @@ android_gethostbyaddr_proxy(struct hostent* hp, const char *addr, socklen_t addr proxy_addr.sun_family = AF_UNIX; strlcpy(proxy_addr.sun_path, "/dev/socket/dnsproxyd", sizeof(proxy_addr.sun_path)); - if (TEMP_FAILURE_RETRY(connect(sock, (const struct sockaddr*) &proxy_addr, + if (TEMP_FAILURE_RETRY(connect(sock, (const struct sockaddr*) (void*) &proxy_addr, sizeof(proxy_addr))) != 0) { close(sock); return -1; @@ -182,7 +182,12 @@ android_gethostbyaddr_proxy(struct hostent* hp, const char *addr, socklen_t addr goto exit; } - if (fprintf(proxy, "gethostbyaddr %s %d %d", addr, addrLen, addrFamily) < 0) { + char buf[INET6_ADDRSTRLEN]; // big enough for IPv4 and IPv6 + const char* addrStr = inet_ntop(addrFamily, addr, &buf, sizeof(buf)); + if (addrStr == NULL) { + goto exit; + } + if (fprintf(proxy, "gethostbyaddr %s %d %d", addrStr, addrLen, addrFamily) < 0) { goto exit; } |