diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-09-29 22:19:56 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-09-29 22:19:56 +0000 |
commit | 28a99b16728d0ffa3d00d5175d3cde8715a74153 (patch) | |
tree | da2f708a6f365728faa8e94a2a8f5c54253e6385 | |
parent | b81ddec8672c0e1574b3b8d44cfb5ce1badfdc6e (diff) | |
download | tor-28a99b16728d0ffa3d00d5175d3cde8715a74153.tar.gz tor-28a99b16728d0ffa3d00d5175d3cde8715a74153.zip |
Forward-port candidate: Fix a crash if we try to find our IP and fail, but we had a good IP for a while previously. Fixes bug reported by Marco Calamari on 27 Sep 2006.
svn:r8538
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/or/config.c | 19 |
2 files changed, 18 insertions, 3 deletions
@@ -9,6 +9,8 @@ Changes in version 0.1.1.24 - 2006-09-xx [ongoing] - If we're a directory mirror and we ask for "all" network status documents, we would forget that's what we wanted and discard most of them when they arrived. + - Don't crash if, after a server has been running for a while, it can't + resolve its hostname. o Minor bugfixes: - Allow Tor to start when RunAsDaemon is set but no logs are set. diff --git a/src/or/config.c b/src/or/config.c index 3043d2ad03..b6873a9e98 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1610,15 +1610,28 @@ resolve_my_address(or_options_t *options, uint32_t *addr_out, uint32_t interface_ip; if (explicit_hostname) { - log_warn(LD_CONFIG,"Could not resolve local Address '%s'. Failing.", - hostname); + log_warn(LD_CONFIG,"Could not resolve local address '%s'. %s.", + hostname, + old_addr ? "Falling back to old address" : "Failing"); + if (old_addr) { + if (hostname_out) + *hostname_out = tor_strdup(hostname); + *addr_out = old_addr; + return 0; + } return -1; } log_notice(LD_CONFIG, "Could not resolve guessed local hostname '%s'. " "Trying something else.", hostname); if (get_interface_address(&interface_ip)) { log_warn(LD_CONFIG, "Could not get local interface IP address. " - "Failing."); + "%s.", old_addr ? "Falling back to old address" : "Failing"); + if (old_addr) { + if (hostname_out) + *hostname_out = tor_strdup(hostname); + *addr_out = old_addr; + return 0; + } return -1; } in.s_addr = htonl(interface_ip); |