mirror of
https://github.com/mfontanini/libtins
synced 2026-01-27 20:24:26 +01:00
According to the C/C++ Standard, for shift operations, the behavior is undefined if the right operand is equal to the width of the promoted left operand. On a 64-bit Windows machine, this causes IP addresses 0.0.0.0 and 255.255.255.255 to have the same internal representation, leading to various issues when using a /0 prefix.
This commit is contained in:
@@ -62,7 +62,7 @@ const AddressRange<IPv4Address> loopback_range = IPv4Address("127.0.0.0") / 8;
|
||||
const AddressRange<IPv4Address> multicast_range = IPv4Address("224.0.0.0") / 4;
|
||||
|
||||
IPv4Address IPv4Address::from_prefix_length(uint32_t prefix_length) {
|
||||
return IPv4Address(Endian::host_to_be(0xffffffff << (32 - prefix_length)));
|
||||
return IPv4Address(prefix_length ? Endian::host_to_be(0xffffffff << (32 - prefix_length)) : 0u);
|
||||
}
|
||||
|
||||
IPv4Address::IPv4Address(uint32_t ip)
|
||||
|
||||
Reference in New Issue
Block a user