diff options
Diffstat (limited to 'server/TetherController.cpp')
| -rw-r--r-- | server/TetherController.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/server/TetherController.cpp b/server/TetherController.cpp index 999d31d6..697bbe46 100644 --- a/server/TetherController.cpp +++ b/server/TetherController.cpp @@ -17,6 +17,7 @@ #include <stdlib.h> #include <errno.h> #include <fcntl.h> +#include <netdb.h> #include <string.h> #include <sys/socket.h> @@ -237,13 +238,13 @@ int TetherController::setDnsForwarders(unsigned netId, char **servers, int numSe for (i = 0; i < numServers; i++) { ALOGD("setDnsForwarders(0x%x %d = '%s')", fwmark.intValue, i, servers[i]); - struct in_addr v4dns; - struct in6_addr v6dns; - - if (!inet_aton(servers[i], &v4dns) && - (inet_pton(AF_INET6, servers[i], &v6dns) != 1)) { + addrinfo *res, hints = { .ai_flags = AI_NUMERICHOST }; + int ret = getaddrinfo(servers[i], NULL, &hints, &res); + freeaddrinfo(res); + if (ret) { ALOGE("Failed to parse DNS server '%s'", servers[i]); mDnsForwarders->clear(); + errno = EINVAL; return -1; } @@ -264,6 +265,7 @@ int TetherController::setDnsForwarders(unsigned netId, char **servers, int numSe if (write(mDaemonFd, daemonCmd, strlen(daemonCmd) +1) < 0) { ALOGE("Failed to send update command to dnsmasq (%s)", strerror(errno)); mDnsForwarders->clear(); + errno = EREMOTEIO; return -1; } } |
