Commit 127e416c authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[master] Check IPv6 mask length

parent 61d7c395
......@@ -45,9 +45,13 @@ const uint8_t bitMask6[]= { 0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
/// @param len prefix length
isc::asiolink::IOAddress firstAddrInPrefix6(const isc::asiolink::IOAddress& prefix,
uint8_t len) {
uint8_t packed[V6ADDRESS_LEN];
if (len > 128) {
isc_throw(isc::BadValue,
"Too large netmask. 0..128 is allowed in IPv6");
}
// First we copy the whole address as 16 bytes.
memcpy(packed, prefix.getAddress().to_v6().to_bytes().data(), 16);
......@@ -104,7 +108,7 @@ isc::asiolink::IOAddress firstAddrInPrefix4(const isc::asiolink::IOAddress& pref
isc::asiolink::IOAddress lastAddrInPrefix4(const isc::asiolink::IOAddress& prefix,
uint8_t len) {
uint32_t addr = prefix;
if (len>32) {
if (len > 32) {
isc_throw(isc::BadValue, "Too large netmask. 0..32 is allowed in IPv4");
}
......@@ -123,6 +127,11 @@ isc::asiolink::IOAddress lastAddrInPrefix6(const isc::asiolink::IOAddress& prefi
uint8_t packed[V6ADDRESS_LEN];
if (len > 128) {
isc_throw(isc::BadValue,
"Too large netmask. 0..128 is allowed in IPv6");
}
// First we copy the whole address as 16 bytes.
memcpy(packed, prefix.getAddress().to_v6().to_bytes().data(), 16);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment