summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/compat.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index c6c218881b..c4e949a6e7 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -513,14 +513,15 @@ int tor_lookup_hostname(const char *name, uint32_t *addr)
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_INET;
hints.ai_socktype = SOCK_STREAM;
- err = getaddrinfo(name, NULL, &hints, &res);
+ err = getaddrinfo(name, NULL, NULL, &res);
if (!err) {
for (res_p = res; res_p; res_p = res_p->ai_next) {
- if (res_p->ai_family == PF_INET &&
- res_p->ai_addrlen == 4) {
- memcpy(addr, res_p->ai_addr, 4);
+ if (res_p->ai_family == AF_INET) {
+ struct sockaddr_in *sin = (struct sockaddr_in *)res_p->ai_addr;
+ memcpy(addr, &sin->sin_addr, 4);
freeaddrinfo(res);
return 0;
+ } else {
}
}
return -1;