From 7739c5c49a3eb191b7c042ead52d7e9d28515672 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 25 Aug 2006 21:02:01 +0000 Subject: r8573@Kushana: nickm | 2006-08-25 16:55:19 -0400 Resolve bug 321 when using dnsworkers: append a period to every address we resolve at the exit node, so that we do not accidentally pick up local addresses, and so that failing searches are retried in the resolver search domains. (This is already solved for eventdns.) svn:r8225 --- src/or/dns.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/or') diff --git a/src/or/dns.c b/src/or/dns.c index f88af4d52d..7d43b016ef 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -944,7 +944,7 @@ dnsworkers_rotate(void) static int dnsworker_main(void *data) { - char address[MAX_ADDRESSLEN]; + char address[MAX_ADDRESSLEN+1]; /* Plus a byte for a final '.' */ unsigned char address_len; char *log_address; char answer[5]; @@ -989,7 +989,13 @@ dnsworker_main(void *data) crypto_thread_cleanup(); spawn_exit(); } - address[address_len] = 0; /* nul terminate it */ + /* Add a period to prevent local domain search, and NUL-terminate. */ + if (address[address_len-1] != '.') { + address[address_len] = '.'; + address[address_len+1] = '\0'; + } else { + address[address_len] = '\0'; + } log_address = esc_for_log(safe_str(address)); result = tor_lookup_hostname(address, &ip); @@ -999,17 +1005,17 @@ dnsworker_main(void *data) switch (result) { case 1: /* XXX result can never be 1, because we set it to -1 above on error */ - log_info(LD_NET,"Could not resolve dest addr %s (transient).", + log_info(LD_NET,"Could not resolve dest addr %s (transient)", log_address); answer[0] = DNS_RESOLVE_FAILED_TRANSIENT; break; case -1: - log_info(LD_NET,"Could not resolve dest addr %s (permanent).", + log_info(LD_NET,"Could not resolve dest addr %s (permanent)", log_address); answer[0] = DNS_RESOLVE_FAILED_PERMANENT; break; case 0: - log_info(LD_NET,"Resolved address %s.", log_address); + log_info(LD_NET,"Resolved address %s", log_address); answer[0] = DNS_RESOLVE_SUCCEEDED; break; } -- cgit v1.2.3-54-g00ecf