[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8538: Forward-port candidate: Fix a crash if we try to find our IP (in tor/branches/tor-0_1_1-patches: . src/or)



Author: nickm
Date: 2006-09-29 18:19:56 -0400 (Fri, 29 Sep 2006)
New Revision: 8538

Modified:
   tor/branches/tor-0_1_1-patches/ChangeLog
   tor/branches/tor-0_1_1-patches/src/or/config.c
Log:
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.

Modified: tor/branches/tor-0_1_1-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_1_1-patches/ChangeLog	2006-09-29 20:13:52 UTC (rev 8537)
+++ tor/branches/tor-0_1_1-patches/ChangeLog	2006-09-29 22:19:56 UTC (rev 8538)
@@ -9,6 +9,8 @@
     - 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.

Modified: tor/branches/tor-0_1_1-patches/src/or/config.c
===================================================================
--- tor/branches/tor-0_1_1-patches/src/or/config.c	2006-09-29 20:13:52 UTC (rev 8537)
+++ tor/branches/tor-0_1_1-patches/src/or/config.c	2006-09-29 22:19:56 UTC (rev 8538)
@@ -1610,15 +1610,28 @@
       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);