Commit 9dcea047 authored by john dickinson's avatar john dickinson
Browse files

addressed issues in review

parent 55ff60c5
......@@ -105,6 +105,19 @@ D2Dhcid::fromClientId(const std::vector<uint8_t>& clientid_data,
// | 255 | i1 | i2 | i3 | i4 | d1 | d2 |...
// +-----+----+----+----+----+----+----+---
if (!clientid_data.empty() && clientid_data[0] == 255) {
if (clientid_data.size() <= 5) {
isc_throw(isc::dhcp_ddns::DhcidRdataComputeError,
"unable to compute DHCID from client identifier, embedded DUID "
"length of: " << clientid_data.size() << ", is too short");
}
// RFC3315 states that the DUID is a type code of 2 octets followed
// by no more then 128 octets. So add the 5 from above and make sure
// the length is not too long.
if (clientid_data.size() > 135) {
isc_throw(isc::dhcp_ddns::DhcidRdataComputeError,
"unable to compute DHCID from client identifier, embedded DUID "
"length of: " << clientid_data.size() << ", is too long");
}
std::vector<uint8_t>::const_iterator start = clientid_data.begin() + 5;
std::vector<uint8_t>::const_iterator end = clientid_data.end();
std::vector<uint8_t> duid(start, end);
......
......@@ -476,13 +476,13 @@ TEST_F(DhcidTest, fromClientIdDUID) {
// Make sure that the DHCID is valid.
EXPECT_EQ(dhcid_ref, dhcid.toStr());
// Make sure that the empty FQDN is not accepted.
std::vector<uint8_t> empty_wire_fqdn;
EXPECT_THROW(dhcid.fromClientId(clientid, empty_wire_fqdn),
// Make sure that a too long client identifier is not accepted.
clientid.resize(136);
EXPECT_THROW(dhcid.fromClientId(clientid, wire_fqdn_),
isc::dhcp_ddns::DhcidRdataComputeError);
// Make sure that the empty client identifier is not accepted.
clientid.clear();
// Make sure that a too short client identifier is not accepted.
clientid.resize(5);
EXPECT_THROW(dhcid.fromClientId(clientid, wire_fqdn_),
isc::dhcp_ddns::DhcidRdataComputeError);
......
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