Kaynağa Gözat

r14583@catbus: nickm | 2007-08-15 17:52:35 -0400
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

Nick Mathewson 17 yıl önce
ebeveyn
işleme
3623a12262
2 değiştirilmiş dosya ile 8 ekleme ve 3 silme
  1. 2 0
      ChangeLog
  2. 6 3
      src/or/connection_edge.c

+ 2 - 0
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

+ 6 - 3
src/or/connection_edge.c

@@ -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);