mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Handle return value from getaddrinfo properly
svn:r3526
This commit is contained in:
parent
efa9bb5535
commit
915202048e
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user