aboutsummaryrefslogtreecommitdiffstats
path: root/libc/netbsd/net/getaddrinfo.c
diff options
context:
space:
mode:
authorSelim Gurun <sgurun@google.com>2012-03-07 17:05:15 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-03-07 17:05:15 -0800
commitdb6d20be77d7a176822db4106dc43605e22c7b39 (patch)
tree86c99b5aa1c3e1f03e7f45b8d2bd29e5af05bcd5 /libc/netbsd/net/getaddrinfo.c
parent36c8c1039fca1c338796c4a8951c31e4fdf1d3b9 (diff)
parent06e1831f194389b6f56ac016ebb52ed5cd430bb2 (diff)
downloadandroid_bionic-db6d20be77d7a176822db4106dc43605e22c7b39.tar.gz
android_bionic-db6d20be77d7a176822db4106dc43605e22c7b39.tar.bz2
android_bionic-db6d20be77d7a176822db4106dc43605e22c7b39.zip
Merge "Prevent potential stall on dns proxy operations."
Diffstat (limited to 'libc/netbsd/net/getaddrinfo.c')
-rw-r--r--libc/netbsd/net/getaddrinfo.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libc/netbsd/net/getaddrinfo.c b/libc/netbsd/net/getaddrinfo.c
index 6ae6e3e43..7dd65ff3a 100644
--- a/libc/netbsd/net/getaddrinfo.c
+++ b/libc/netbsd/net/getaddrinfo.c
@@ -130,6 +130,9 @@ static const char in6_loopback[] = {
};
#endif
+// This should be synchronized to ResponseCode.h
+static const int DnsProxyQueryResult = 222;
+
static const struct afd {
int a_af;
int a_addrlen;
@@ -476,12 +479,15 @@ android_getaddrinfo_proxy(
goto exit;
}
- int remote_rv;
- if (fread(&remote_rv, sizeof(int), 1, proxy) != 1) {
+ char buf[5];
+ // read result code for gethostbyaddr
+ if (fread(buf, 1, sizeof(buf), proxy) != sizeof(buf)) {
goto exit;
}
- if (remote_rv != 0) {
+ int result_code = (int)strtol(buf, NULL, 10);
+ // verify the code itself
+ if (result_code != DnsProxyQueryResult ) {
goto exit;
}