mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 13:53:31 +01:00
Fix bug reported by peter palfrader: an empty address is unresolvable, but not an occasion for an assertion failure in a dnsworker.
svn:r2015
This commit is contained in:
parent
fe099bc21e
commit
d5e275ddf4
@ -1709,7 +1709,10 @@ int tor_lookup_hostname(const char *name, uint32_t *addr)
|
||||
struct in_addr iaddr;
|
||||
struct hostent *ent;
|
||||
tor_assert(addr);
|
||||
if (tor_inet_aton(name, &iaddr)) {
|
||||
if (!*name) {
|
||||
/* Empty address is an error. */
|
||||
return -1;
|
||||
} if (tor_inet_aton(name, &iaddr)) {
|
||||
/* It's an IP. */
|
||||
memcpy(addr, &iaddr.s_addr, 4);
|
||||
return 0;
|
||||
|
@ -648,9 +648,8 @@ static int dnsworker_main(void *data) {
|
||||
log_fn(LOG_INFO,"dnsworker exiting because tor process died.");
|
||||
spawn_exit();
|
||||
}
|
||||
tor_assert(address_len > 0);
|
||||
|
||||
if(read_all(fd, address, address_len, 1) != address_len) {
|
||||
if(address_len && read_all(fd, address, address_len, 1) != address_len) {
|
||||
log_fn(LOG_ERR,"read hostname failed. Child exiting.");
|
||||
spawn_exit();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user