mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Adapt patch from Adam Langley: fix possible memory leak in tor_lookup_hostname
svn:r4326
This commit is contained in:
parent
a92ff1c4e9
commit
1d9bc936c2
@ -526,8 +526,9 @@ int tor_lookup_hostname(const char *name, uint32_t *addr)
|
||||
} else {
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
int err;
|
||||
struct addrinfo *res, *res_p;
|
||||
struct addrinfo *res=NULL, *res_p;
|
||||
struct addrinfo hints;
|
||||
int result = -1;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = PF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
@ -537,14 +538,13 @@ int tor_lookup_hostname(const char *name, uint32_t *addr)
|
||||
if (res_p->ai_family == AF_INET) {
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)res_p->ai_addr;
|
||||
memcpy(addr, &sin->sin_addr, 4);
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
freeaddrinfo(res);
|
||||
return 0;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (err == EAI_AGAIN) ? 1 : -1;
|
||||
#else
|
||||
struct hostent *ent;
|
||||
|
Loading…
Reference in New Issue
Block a user