Commit caefbb6f authored by Paul Selkirk's avatar Paul Selkirk
Browse files

[2521] DHCDID RDATA cannot be empty

parent 5045f86b
......@@ -48,10 +48,11 @@ DHCID::constructFromLexer(MasterLexer& lexer) {
}
lexer.ungetToken();
// missing digest data is okay
if (digest_txt.size() > 0) {
decodeBase64(digest_txt, digest_);
if (digest_txt.size() == 0) {
isc_throw(InvalidRdataText, "Missing DHCID RDATA");
}
decodeBase64(digest_txt, digest_);
}
/// \brief Constructor from string.
......@@ -89,7 +90,9 @@ DHCID::DHCID(const std::string& dhcid_str) {
/// The \c lexer should point to the beginning of valid textual representation
/// of a DHCID RDATA.
///
/// \throw MasterLexer::LexerError General parsing error such as missing field.
/// \throw InvalidRdataText on empty string.
/// \throw BadValue if the text is not valid base-64.
/// \throw MasterLexer::LexerError General parsing error.
///
/// \param lexer A \c MasterLexer object parsing a master file for the
/// RDATA to be created
......
......@@ -45,8 +45,8 @@ protected:
rdata_str, rdata_dhcid, false, false);
}
void checkFromText_InvalidLength(const string& rdata_str) {
checkFromText<in::DHCID, InvalidRdataLength, InvalidRdataLength>(
void checkFromText_InvalidText(const string& rdata_str) {
checkFromText<in::DHCID, InvalidRdataText, InvalidRdataText>(
rdata_str, rdata_dhcid, true, true);
}
......@@ -74,9 +74,6 @@ protected:
TEST_F(Rdata_DHCID_Test, fromText) {
EXPECT_EQ(dhcid_txt, rdata_dhcid.toText());
// missing digest data is okay
EXPECT_NO_THROW(const in::DHCID digest(""));
// Space in digest data is OK
checkFromText_None(
"0LIg0LvQtdGB0YMg 0YDQvtC00LjQu9Cw 0YHRjCDRkdC70L7R h9C60LA=");
......@@ -95,6 +92,10 @@ TEST_F(Rdata_DHCID_Test, fromText) {
}
TEST_F(Rdata_DHCID_Test, badText) {
// missing digest data
checkFromText_InvalidText("");
// invalid base64
checkFromText_BadValue("EEeeeeeeEEEeeeeeeGaaahAAAAAAAAHHHHHHHHHHH!=");
// unterminated multi-line base64
......
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