aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2016-06-08 22:47:23 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-06-08 22:47:23 +0000
commit2193939e53e05c89a90b708df14632ba2401a5ad (patch)
tree0c40297c192d8117f76b0bf9941dfb5a89cd0971
parent5c19a4c5d8fe941ffb312e99597e189f2c959126 (diff)
parent40cc8034e390c298fd8c130658371babfe80402d (diff)
downloadchromium-libpac-2193939e53e05c89a90b708df14632ba2401a5ad.tar.gz
Merge \\"Fix for PAC script function dnsResolve.\\" am: 94b900307e
am: 40cc8034e3 Change-Id: I21894dc69c26971d05aeebede1c428ad375d34f1
-rw-r--r--src/proxy_resolver_js_bindings.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/proxy_resolver_js_bindings.cc b/src/proxy_resolver_js_bindings.cc
index 897fde4..0686f23 100644
--- a/src/proxy_resolver_js_bindings.cc
+++ b/src/proxy_resolver_js_bindings.cc
@@ -5,6 +5,7 @@
#include "proxy_resolver_js_bindings.h"
#include "proxy_resolver_v8.h"
+#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <cstddef>
@@ -64,10 +65,16 @@ class DefaultJSBindings : public ProxyResolverJSBindings {
std::string* first_ip_address) {
struct hostent* he = gethostbyname(host.c_str());
- if (he == NULL) {
+ if (he == NULL || he->h_addr == NULL || he->h_addrtype != AF_INET) {
return false;
}
- *first_ip_address = std::string(he->h_addr);
+
+ char tmp[INET_ADDRSTRLEN];
+ if (inet_ntop(he->h_addrtype, he->h_addr, tmp, sizeof(tmp)) == NULL) {
+ return false;
+ }
+
+ *first_ip_address = std::string(tmp);
return true;
}