From 3623a12262abb8a47f955d78d4f496377ee13872 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 15 Aug 2007 21:53:34 +0000 Subject: [PATCH] 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 --- ChangeLog | 2 ++ src/or/connection_edge.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32f8dfcbd2..1ec7eb14b0 100644 --- 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 diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 9a02357c39..77a95f6764 100644 --- a/src/or/connection_edge.c +++ b/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); -- 2.47.3