Commit 885821d1 authored by Paul Selkirk's avatar Paul Selkirk
Browse files

[2521] better way of handling empty DHCID RDATA

parent 225a1e04
......@@ -33,9 +33,10 @@ using namespace isc::util::encode;
void
DHCID::constructFromLexer(MasterLexer& lexer) {
string digest_txt;
string digest_part;
string digest_txt = lexer.getNextToken(MasterToken::STRING).getString();
// Whitespace is allowed within base64 text, so read to the end of input.
string digest_part;
while (true) {
const MasterToken& token =
lexer.getNextToken(MasterToken::STRING, true);
......@@ -48,10 +49,6 @@ DHCID::constructFromLexer(MasterLexer& lexer) {
}
lexer.ungetToken();
if (digest_txt.size() == 0) {
isc_throw(InvalidRdataText, "Missing DHCID RDATA");
}
decodeBase64(digest_txt, digest_);
}
......@@ -90,9 +87,8 @@ DHCID::DHCID(const std::string& dhcid_str) {
/// The \c lexer should point to the beginning of valid textual representation
/// of a DHCID RDATA.
///
/// \throw InvalidRdataText on empty string.
/// \throw BadValue if the text is not valid base-64.
/// \throw MasterLexer::LexerError General parsing error.
/// \throw MasterLexer::LexerError General parsing error such as missing field.
///
/// \param lexer A \c MasterLexer object parsing a master file for the
/// RDATA to be created
......
......@@ -93,7 +93,7 @@ TEST_F(Rdata_DHCID_Test, fromText) {
TEST_F(Rdata_DHCID_Test, badText) {
// missing digest data
checkFromText_InvalidText("");
checkFromText_LexerError("");
// invalid base64
checkFromText_BadValue("EEeeeeeeEEEeeeeeeGaaahAAAAAAAAHHHHHHHHHHH!=");
......
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