BIND 10 master, updated. 73179cbc2030af0c6a6298874161386613e0b9f9 [master] Add ChangeLog entry for #3287

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jan 28 02:27:48 UTC 2014


The branch, master has been updated
       via  73179cbc2030af0c6a6298874161386613e0b9f9 (commit)
       via  2f26d781704618c6007ba896ad3d9e0c107d04b0 (commit)
       via  d631937eaeaa137fc1e832993b17d8e331b9b73c (commit)
       via  c1187e4ae7d409c94a73e6b10fa00751d302e05d (commit)
       via  e71ef05f8698763d2e604a55aa7e39ac824241d8 (commit)
       via  a99f8f2985db8650de25810cbb74cf5752c9e703 (commit)
       via  b3f844906409066e56efb339e0ff22e18d70386f (commit)
       via  56148b90078653c55088d7a275a11b480dc32b22 (commit)
      from  b26f6251fc5956a22bfe5a63066cd3a1545af32d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 73179cbc2030af0c6a6298874161386613e0b9f9
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jan 28 07:43:53 2014 +0530

    [master] Add ChangeLog entry for #3287

commit 2f26d781704618c6007ba896ad3d9e0c107d04b0
Merge: b26f625 d631937
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jan 28 07:26:24 2014 +0530

    Merge branch 'trac3287'

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                 |    7 +++++++
 src/lib/dns/rdata/generic/sshfp_44.cc     |   30 +++++++++++++++------------
 src/lib/dns/rdata/generic/sshfp_44.h      |    4 +++-
 src/lib/dns/tests/rdata_sshfp_unittest.cc |   32 ++++++++++++++++++-----------
 4 files changed, 47 insertions(+), 26 deletions(-)

-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index bd2331f..af28061 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+739.	[bug]		muks
+	Various minor updates were made to the SSHFP RDATA parser. Mainly,
+	the SSHFP constructor no longer throws an isc::BadValue exception.
+	generic::SSHFP::getFingerprintLen() was also renamed to
+	getFingerprintLength().
+	(Trac #3287, git 2f26d781704618c6007ba896ad3d9e0c107d04b0)
+
 738.	[bug]		muks
 	b10-auth now correctly processes NXDOMAIN results in the root zone
 	when using a SQLite3 data source.
diff --git a/src/lib/dns/rdata/generic/sshfp_44.cc b/src/lib/dns/rdata/generic/sshfp_44.cc
index 2865ed1..4c1e832 100644
--- a/src/lib/dns/rdata/generic/sshfp_44.cc
+++ b/src/lib/dns/rdata/generic/sshfp_44.cc
@@ -14,8 +14,6 @@
 
 #include <config.h>
 
-#include <string>
-
 #include <boost/lexical_cast.hpp>
 
 #include <exceptions/exceptions.h>
@@ -38,7 +36,7 @@ using namespace isc::util::encode;
 struct SSHFPImpl {
     // straightforward representation of SSHFP RDATA fields
     SSHFPImpl(uint8_t algorithm, uint8_t fingerprint_type,
-              vector<uint8_t>& fingerprint) :
+              const vector<uint8_t>& fingerprint) :
         algorithm_(algorithm),
         fingerprint_type_(fingerprint_type),
         fingerprint_(fingerprint)
@@ -82,7 +80,11 @@ SSHFP::constructFromLexer(MasterLexer& lexer) {
     // If fingerprint is missing, it's OK. See the API documentation of the
     // constructor.
     if (fingerprint_str.size() > 0) {
-        decodeHex(fingerprint_str, fingerprint);
+        try {
+            decodeHex(fingerprint_str, fingerprint);
+        } catch (const isc::BadValue& e) {
+            isc_throw(InvalidRdataText, "Bad SSHFP fingerprint: " << e.what());
+        }
     }
 
     return (new SSHFPImpl(algorithm, fingerprint_type, fingerprint));
@@ -102,8 +104,9 @@ SSHFP::constructFromLexer(MasterLexer& lexer) {
 /// valid hex encoding of the fingerprint. For compatibility with BIND 9,
 /// whitespace is allowed in the hex text (RFC4255 is silent on the matter).
 ///
-/// \throw InvalidRdataText if any fields are missing, out of their valid
-/// ranges, or incorrect.
+/// \throw InvalidRdataText if any fields are missing, are out of their
+/// valid ranges or are incorrect, or if the fingerprint is not a valid
+/// hex string.
 ///
 /// \param sshfp_str A string containing the RDATA to be created
 SSHFP::SSHFP(const string& sshfp_str) :
@@ -128,9 +131,6 @@ SSHFP::SSHFP(const string& sshfp_str) :
     } catch (const MasterLexer::LexerError& ex) {
         isc_throw(InvalidRdataText, "Failed to construct SSHFP from '" <<
                   sshfp_str << "': " << ex.what());
-    } catch (const isc::BadValue& e) {
-        isc_throw(InvalidRdataText,
-                  "Bad SSHFP fingerprint: " << e.what());
     }
 
     impl_ = impl_ptr.release();
@@ -142,9 +142,8 @@ SSHFP::SSHFP(const string& sshfp_str) :
 /// of an SSHFP RDATA.
 ///
 /// \throw MasterLexer::LexerError General parsing error such as missing field.
-/// \throw InvalidRdataText Fields are out of their valid range, or are
-/// incorrect.
-/// \throw BadValue Fingerprint is not a valid hex string.
+/// \throw InvalidRdataText Fields are out of their valid range or are
+/// incorrect, or if the fingerprint is not a valid hex string.
 ///
 /// \param lexer A \c MasterLexer object parsing a master file for the
 /// RDATA to be created
@@ -293,8 +292,13 @@ SSHFP::getFingerprintType() const {
     return (impl_->fingerprint_type_);
 }
 
+const std::vector<uint8_t>&
+SSHFP::getFingerprint() const {
+    return (impl_->fingerprint_);
+}
+
 size_t
-SSHFP::getFingerprintLen() const {
+SSHFP::getFingerprintLength() const {
     return (impl_->fingerprint_.size());
 }
 
diff --git a/src/lib/dns/rdata/generic/sshfp_44.h b/src/lib/dns/rdata/generic/sshfp_44.h
index 28ce0f3..85ae806 100644
--- a/src/lib/dns/rdata/generic/sshfp_44.h
+++ b/src/lib/dns/rdata/generic/sshfp_44.h
@@ -17,6 +17,7 @@
 #include <stdint.h>
 
 #include <string>
+#include <vector>
 
 #include <dns/name.h>
 #include <dns/rdata.h>
@@ -45,7 +46,8 @@ public:
     ///
     uint8_t getAlgorithmNumber() const;
     uint8_t getFingerprintType() const;
-    size_t getFingerprintLen() const;
+    const std::vector<uint8_t>& getFingerprint() const;
+    size_t getFingerprintLength() const;
 
 private:
     SSHFPImpl* constructFromLexer(MasterLexer& lexer);
diff --git a/src/lib/dns/tests/rdata_sshfp_unittest.cc b/src/lib/dns/tests/rdata_sshfp_unittest.cc
index b85dfa5..a327557 100644
--- a/src/lib/dns/tests/rdata_sshfp_unittest.cc
+++ b/src/lib/dns/tests/rdata_sshfp_unittest.cc
@@ -59,11 +59,6 @@ protected:
                 rdata_str, rdata_sshfp, true, true);
     }
 
-    void checkFromText_BadValue(const string& rdata_str) {
-        checkFromText<generic::SSHFP, InvalidRdataText, BadValue>(
-            rdata_str, rdata_sshfp, true, true);
-    }
-
     void checkFromText_BadString(const string& rdata_str) {
         checkFromText
             <generic::SSHFP, InvalidRdataText, isc::Exception>(
@@ -138,8 +133,8 @@ TEST_F(Rdata_SSHFP_Test, badText) {
     checkFromText_LexerError("1");
     checkFromText_LexerError("ONE 2 123456789abcdef67890123456789abcdef67890");
     checkFromText_LexerError("1 TWO 123456789abcdef67890123456789abcdef67890");
-    checkFromText_BadValue("1 2 BUCKLEMYSHOE");
-    checkFromText_BadValue(sshfp_txt + " extra text");
+    checkFromText_InvalidText("1 2 BUCKLEMYSHOE");
+    checkFromText_InvalidText(sshfp_txt + " extra text");
 
     // yes, these are redundant to the last test cases in algorithmTypes
     checkFromText_InvalidText(
@@ -232,7 +227,8 @@ TEST_F(Rdata_SSHFP_Test, toWire) {
     this->obuffer.clear();
     rdata_sshfp.toWire(this->obuffer);
 
-    EXPECT_EQ(22, this->obuffer.getLength());
+    EXPECT_EQ(sizeof (rdata_sshfp_wiredata),
+              this->obuffer.getLength());
 
     EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
                         this->obuffer.getData(),
@@ -254,8 +250,20 @@ TEST_F(Rdata_SSHFP_Test, getFingerprintType) {
     EXPECT_EQ(1, rdata_sshfp.getFingerprintType());
 }
 
-TEST_F(Rdata_SSHFP_Test, getFingerprintLen) {
-    EXPECT_EQ(20, rdata_sshfp.getFingerprintLen());
+TEST_F(Rdata_SSHFP_Test, getFingerprint) {
+    const std::vector<uint8_t>& fingerprint =
+        rdata_sshfp.getFingerprint();
+
+    EXPECT_EQ(rdata_sshfp.getFingerprintLength(),
+              fingerprint.size());
+    for (int i = 0; i < fingerprint.size(); ++i) {
+        EXPECT_EQ(rdata_sshfp_wiredata[i + 2],
+                  fingerprint.at(i));
+    }
+}
+
+TEST_F(Rdata_SSHFP_Test, getFingerprintLength) {
+    EXPECT_EQ(20, rdata_sshfp.getFingerprintLength());
 }
 
 TEST_F(Rdata_SSHFP_Test, emptyFingerprintFromWire) {
@@ -273,7 +281,7 @@ TEST_F(Rdata_SSHFP_Test, emptyFingerprintFromWire) {
 
     EXPECT_EQ(4, rdf.getAlgorithmNumber());
     EXPECT_EQ(9, rdf.getFingerprintType());
-    EXPECT_EQ(0, rdf.getFingerprintLen());
+    EXPECT_EQ(0, rdf.getFingerprintLength());
 
     this->obuffer.clear();
     rdf.toWire(this->obuffer);
@@ -297,7 +305,7 @@ TEST_F(Rdata_SSHFP_Test, emptyFingerprintFromString) {
 
     EXPECT_EQ(5, rdata_sshfp2.getAlgorithmNumber());
     EXPECT_EQ(6, rdata_sshfp2.getFingerprintType());
-    EXPECT_EQ(0, rdata_sshfp2.getFingerprintLen());
+    EXPECT_EQ(0, rdata_sshfp2.getFingerprintLength());
 
     this->obuffer.clear();
     rdata_sshfp2.toWire(this->obuffer);



More information about the bind10-changes mailing list