diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-08-25 21:02:01 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-08-25 21:02:01 +0000 |
commit | 7739c5c49a3eb191b7c042ead52d7e9d28515672 (patch) | |
tree | 7a11e96900b4c8c4475f2767da80a32d71ba2c2b /src | |
parent | c82c4a9e8b03e7430c5783256af1d24e2c9b3cdd (diff) | |
download | tor-7739c5c49a3eb191b7c042ead52d7e9d28515672.tar.gz tor-7739c5c49a3eb191b7c042ead52d7e9d28515672.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/or/dns.c | 16 |
1 files changed, 11 insertions, 5 deletions
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; } |