From d5e275ddf4ee700053f028e2255d9b90fa885d18 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 6 Jul 2004 23:25:21 +0000 Subject: [PATCH] Fix bug reported by peter palfrader: an empty address is unresolvable, but not an occasion for an assertion failure in a dnsworker. svn:r2015 --- src/common/util.c | 5 ++++- src/or/dns.c | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/util.c b/src/common/util.c index 27d43337af..cc90495bec 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -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; diff --git a/src/or/dns.c b/src/or/dns.c index 851041d779..3e16b6b643 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -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(); }