diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-08-15 21:53:34 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-08-15 21:53:34 +0000 |
commit | 3623a12262abb8a47f955d78d4f496377ee13872 (patch) | |
tree | 1e62a331b6a04fdc2a26eb1f8b81eab436b4392f /src | |
parent | d945038c05c0f689d95bc65eb7bc4dbec8dc3e29 (diff) | |
download | tor-3623a12262abb8a47f955d78d4f496377ee13872.tar.gz tor-3623a12262abb8a47f955d78d4f496377ee13872.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/or/connection_edge.c | 9 |
1 files changed, 6 insertions, 3 deletions
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); |