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:
Nick Mathewson 2004-07-06 23:25:21 +00:00
parent fe099bc21e
commit d5e275ddf4
2 changed files with 5 additions and 3 deletions

View File

@ -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;

View File

@ -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();
}