2061. [bug*] fdupont
- Enforce length limits on host identifier (20 for hardware
- address, 128 for DUID and other types).
+ Enforce length limits on host identifier (20 bytes for
+ hardware address, 128 bytes for DUID and other types).
(Gitlab #2557)
2060. [build] andrei
// If the identifier lacks opening and closing quote, this will return
// an empty value, in which case we'll try to decode it as a string of
// hexadecimal digits.
+ bool too_long = false;
try {
std::vector<uint8_t> binary = util::str::quotedStringToBinary(identifier);
if (binary.empty()) {
size_t len = binary.size();
if (len > getIdentifierMaxLength(identifier_type_)) {
// Message does not matter as it will be replaced below...
- isc_throw(BadValue, "too long client identifier");
+ too_long = true;
+ isc_throw(BadValue, "too long client identifier type " << name
+ << " length " << len);
}
// Successfully decoded the identifier, so let's use it.
} catch (...) {
// The string doesn't match any known pattern, so we have to
// report an error at this point.
+ if (too_long) {
+ throw;
+ }
isc_throw(isc::BadValue, "invalid host identifier value '"
- << identifier << "'");
+ << identifier << "'");
}
}
// Use too long HW address.
string too_long = "00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f";
too_long += ":10:11:12:13:14";
- expected = "invalid host identifier value '" + too_long + "'";
+ expected = "too long client identifier type hw-address length 21";
EXPECT_THROW_MSG(Host(too_long, "hw-address", SubnetID(1), SubnetID(2),
IOAddress("192.0.2.3"), "somehost.example.org"),
isc::BadValue, expected);
too_long += ":60:61:62:63:64:65:66:67:68:69:6a:6b:6c:6d:6e:6f";
too_long += ":70:71:72:73:74:75:76:77:78:79:7a:7b:7c:7d:7e:7f";
too_long += ":ff";
- expected = "invalid host identifier value '" + too_long + "'";
+ expected = "too long client identifier type duid length 129";
EXPECT_THROW_MSG(Host(too_long, "duid", SubnetID(1), SubnetID(2),
IOAddress("192.0.2.3"), "somehost.example.org"),
isc::BadValue, expected);
+ expected = "too long client identifier type circuit-id length 129";
EXPECT_THROW_MSG(Host(too_long, "circuit-id", SubnetID(1), SubnetID(2),
IOAddress("192.0.2.3"), "somehost.example.org"),
isc::BadValue, expected);