mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Fix a strdup() of uninitialized buffer in addressmap_get_virtual_address
Partial revert of 22f723e4a3
.
Bugfix on 0.2.3.0-alpha
This commit is contained in:
parent
d4b265d692
commit
3bc235d979
@ -1200,6 +1200,7 @@ addressmap_get_virtual_address(int type)
|
|||||||
} else if (type == RESOLVED_TYPE_IPV4) {
|
} else if (type == RESOLVED_TYPE_IPV4) {
|
||||||
// This is an imperfect estimate of how many addresses are available, but
|
// This is an imperfect estimate of how many addresses are available, but
|
||||||
// that's ok.
|
// that's ok.
|
||||||
|
struct in_addr in;
|
||||||
uint32_t available = 1u << (32-virtual_addr_netmask_bits);
|
uint32_t available = 1u << (32-virtual_addr_netmask_bits);
|
||||||
while (available) {
|
while (available) {
|
||||||
/* Don't hand out any .0 or .255 address. */
|
/* Don't hand out any .0 or .255 address. */
|
||||||
@ -1211,7 +1212,9 @@ addressmap_get_virtual_address(int type)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!strmap_get(addressmap, fmt_addr32(next_virtual_addr))) {
|
in.s_addr = htonl(next_virtual_addr);
|
||||||
|
tor_inet_ntoa(&in, buf, sizeof(buf));
|
||||||
|
if (!strmap_get(addressmap, buf)) {
|
||||||
++next_virtual_addr;
|
++next_virtual_addr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user