]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r14583@catbus: nickm | 2007-08-15 17:52:35 -0400
authorNick Mathewson <nickm@torproject.org>
Wed, 15 Aug 2007 21:53:34 +0000 (21:53 +0000)
committerNick Mathewson <nickm@torproject.org>
Wed, 15 Aug 2007 21:53:34 +0000 (21:53 +0000)
 Fix a bug caught by Kate: when we switched from masks to bits in 0.2.0.3-alpha, we added a spurious ! that made us never believe that any address fell inside a virtual address range.  While we're at it, save a trip around the loop in the common case.

svn:r11129

ChangeLog
src/or/connection_edge.c

index 32f8dfcbd2848304cb2c5aba3bf1b2365cc63af9..1ec7eb14b04539aa89ec3a4ea5d12fabdc2397ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,8 @@ Changes in version 0.2.0.5-alpha - 2007-??-??
       where no controller could authenticate. Now we exit.
     - If we require CookieAuthentication, stop generating a new cookie
       every time we change any piece of our config.
+    - Fix a bug with AutomapHostsOnResolve that would always cause the second
+      request to fail.  Bug reported by Kate.  Bugfix on 0.2.0.3-alpha.
 
 
 Changes in version 0.2.0.4-alpha - 2007-08-01
index 9a02357c39726c27970511d70cdf902610cc860c..77a95f67641d8e671630ae7a39902e29d950e78c 100644 (file)
@@ -992,6 +992,7 @@ addressmap_get_virtual_address(int type)
 {
   char buf[64];
   struct in_addr in;
+  tor_assert(addressmap);
 
   if (type == RESOLVED_TYPE_HOSTNAME) {
     char rand[10];
@@ -1013,8 +1014,10 @@ addressmap_get_virtual_address(int type)
       }
       in.s_addr = htonl(next_virtual_addr);
       tor_inet_ntoa(&in, buf, sizeof(buf));
-      if (!strmap_get(addressmap, buf))
+      if (!strmap_get(addressmap, buf)) {
+        ++next_virtual_addr;
         break;
+      }
 
       ++next_virtual_addr;
       --available;
@@ -1023,8 +1026,8 @@ addressmap_get_virtual_address(int type)
         log_warn(LD_CONFIG, "Ran out of virtual addresses!");
         return NULL;
       }
-      if (!addr_mask_cmp_bits(next_virtual_addr, virtual_addr_network,
-                              virtual_addr_netmask_bits))
+      if (addr_mask_cmp_bits(next_virtual_addr, virtual_addr_network,
+                             virtual_addr_netmask_bits))
         next_virtual_addr = virtual_addr_network;
     }
     return tor_strdup(buf);