aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-02-03 23:13:36 +0000
committerNick Mathewson <nickm@torproject.org>2005-02-03 23:13:36 +0000
commit915202048edc9463babb1de829809b2ae7410758 (patch)
tree238437f0a6cde2032dbfe868bc7679fbcb9f41ef /src/common
parentefa9bb55351e54026e66d9b28eec14f143e62544 (diff)
downloadtor-915202048edc9463babb1de829809b2ae7410758.tar
tor-915202048edc9463babb1de829809b2ae7410758.tar.gz
Handle return value from getaddrinfo properly
svn:r3526
Diffstat (limited to 'src/common')
-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 c6c218881..c4e949a6e 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;