Browse Source

[2521] better way of handling empty DHCID RDATA

Paul Selkirk 12 years ago
parent
commit
885821d166
2 changed files with 5 additions and 9 deletions
  1. 4 8
      src/lib/dns/rdata/in_1/dhcid_49.cc
  2. 1 1
      src/lib/dns/tests/rdata_dhcid_unittest.cc

+ 4 - 8
src/lib/dns/rdata/in_1/dhcid_49.cc

@@ -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

+ 1 - 1
src/lib/dns/tests/rdata_dhcid_unittest.cc

@@ -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!=");