From 632c3f8d564a6ab343f81f0ea87ef5637371982f Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Thu, 12 Aug 2004 06:27:11 +0000 Subject: [PATCH] backport: Stop dnsworkers from triggering an assert failure when you ask them to resolve the host "". svn:r2227 --- branches/tor-0_0_7-patches/ChangeLog | 5 +++++ branches/tor-0_0_7-patches/configure.in | 2 +- branches/tor-0_0_7-patches/src/common/util.c | 5 ++++- branches/tor-0_0_7-patches/src/or/dns.c | 3 +-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/branches/tor-0_0_7-patches/ChangeLog b/branches/tor-0_0_7-patches/ChangeLog index 4cfd901f33..b185e7a8f0 100644 --- a/branches/tor-0_0_7-patches/ChangeLog +++ b/branches/tor-0_0_7-patches/ChangeLog @@ -1,3 +1,8 @@ +Changes in version 0.0.7.3 - 2004-08-12 + o Stop dnsworkers from triggering an assert failure when you + ask them to resolve the host "". + + Changes in version 0.0.7.2 - 2004-07-07 o A better fix for the 0.0.0.0 problem, that will hopefully eliminate the remaining related assertion failures. diff --git a/branches/tor-0_0_7-patches/configure.in b/branches/tor-0_0_7-patches/configure.in index ed3aa18948..064f6f8b21 100644 --- a/branches/tor-0_0_7-patches/configure.in +++ b/branches/tor-0_0_7-patches/configure.in @@ -1,6 +1,6 @@ AC_INIT -AM_INIT_AUTOMAKE(tor, 0.0.7.2) +AM_INIT_AUTOMAKE(tor, 0.0.7.3) AM_CONFIG_HEADER(orconfig.h) AC_CANONICAL_HOST diff --git a/branches/tor-0_0_7-patches/src/common/util.c b/branches/tor-0_0_7-patches/src/common/util.c index ce9062fd92..25e42dd4c8 100644 --- a/branches/tor-0_0_7-patches/src/common/util.c +++ b/branches/tor-0_0_7-patches/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; + } else if (tor_inet_aton(name, &iaddr)) { /* It's an IP. */ memcpy(addr, &iaddr.s_addr, 4); return 0; diff --git a/branches/tor-0_0_7-patches/src/or/dns.c b/branches/tor-0_0_7-patches/src/or/dns.c index b9d7c40b36..e09fa8e1a6 100644 --- a/branches/tor-0_0_7-patches/src/or/dns.c +++ b/branches/tor-0_0_7-patches/src/or/dns.c @@ -599,9 +599,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(); }