BIND 10 trac2124, updated. 2c8689536e71f5258ecf01b7fdc5c00644e1feeb [2124] Don't catch InvalidBufferPosition when parsing wiredata

BIND 10 source code commits bind10-changes at lists.isc.org
Sun Jul 29 21:04:35 UTC 2012


The branch, trac2124 has been updated
       via  2c8689536e71f5258ecf01b7fdc5c00644e1feeb (commit)
       via  9b88b6be9672b0f0c683cf51fe9a23c5332d0300 (commit)
      from  5a7c29f6d80ca982c4c48357af6833381268b590 (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 2c8689536e71f5258ecf01b7fdc5c00644e1feeb
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Jul 30 02:33:18 2012 +0530

    [2124] Don't catch InvalidBufferPosition when parsing wiredata

commit 9b88b6be9672b0f0c683cf51fe9a23c5332d0300
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Jul 30 02:23:52 2012 +0530

    [2124] Rewrite code to avoid duplication

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

Summary of changes:
 src/lib/dns/rdata/generic/sshfp_44.cc     |   39 ++++++++++++++---------------
 src/lib/dns/tests/rdata_sshfp_unittest.cc |    6 ++---
 2 files changed, 22 insertions(+), 23 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/rdata/generic/sshfp_44.cc b/src/lib/dns/rdata/generic/sshfp_44.cc
index e87134b..189f9e6 100644
--- a/src/lib/dns/rdata/generic/sshfp_44.cc
+++ b/src/lib/dns/rdata/generic/sshfp_44.cc
@@ -40,18 +40,13 @@ SSHFP::SSHFP(InputBuffer& buffer, size_t rdata_len) {
         isc_throw(InvalidRdataLength, "SSHFP record too short");
     }
 
-    try {
-        algorithm_ = buffer.readUint8();
-        fingerprint_type_ = buffer.readUint8();
+    algorithm_ = buffer.readUint8();
+    fingerprint_type_ = buffer.readUint8();
 
-        rdata_len -= 2;
-        if (rdata_len > 0) {
-            fingerprint_.resize(rdata_len);
-            buffer.readData(&fingerprint_[0], rdata_len);
-        }
-    } catch (const isc::util::InvalidBufferPosition& e) {
-        isc_throw(InvalidRdataLength,
-                  "SSHFP record shorter than RDATA len: " << e.what());
+    rdata_len -= 2;
+    if (rdata_len > 0) {
+        fingerprint_.resize(rdata_len);
+        buffer.readData(&fingerprint_[0], rdata_len);
     }
 }
 
@@ -153,17 +148,21 @@ SSHFP::compare(const Rdata& other) const {
     const size_t this_len = fingerprint_.size();
     const size_t other_len = other_sshfp.fingerprint_.size();
     const size_t cmplen = min(this_len, other_len);
-    if (cmplen == 0) {
-        return ((this_len == other_len)
-                ? 0 : (this_len < other_len) ? -1 : 1);
+
+    if (cmplen > 0) {
+        const int cmp = memcmp(&fingerprint_[0], &other_sshfp.fingerprint_[0],
+                               cmplen);
+        if (cmp != 0) {
+            return (cmp);
+        }
     }
-    const int cmp = memcmp(&fingerprint_[0], &other_sshfp.fingerprint_[0],
-                           cmplen);
-    if (cmp != 0) {
-        return (cmp);
+
+    if (this_len == other_len) {
+        return (0);
+    } else if (this_len < other_len) {
+        return (-1);
     } else {
-        return ((this_len == other_len)
-                ? 0 : (this_len < other_len) ? -1 : 1);
+        return (1);
     }
 }
 
diff --git a/src/lib/dns/tests/rdata_sshfp_unittest.cc b/src/lib/dns/tests/rdata_sshfp_unittest.cc
index cfb0d58..dccd8b1 100644
--- a/src/lib/dns/tests/rdata_sshfp_unittest.cc
+++ b/src/lib/dns/tests/rdata_sshfp_unittest.cc
@@ -141,17 +141,17 @@ TEST_F(Rdata_SSHFP_Test, createFromWire) {
     // fingerprint is shorter than rdata len
     EXPECT_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
                                       "rdata_sshfp_fromWire9"),
-                 InvalidRdataLength);
+                 InvalidBufferPosition);
 
     // fingerprint is missing
     EXPECT_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
                                       "rdata_sshfp_fromWire10"),
-                 InvalidRdataLength);
+                 InvalidBufferPosition);
 
     // all rdata is missing
     EXPECT_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
                                       "rdata_sshfp_fromWire11"),
-                 InvalidRdataLength);
+                 InvalidBufferPosition);
 }
 
 TEST_F(Rdata_SSHFP_Test, toText) {



More information about the bind10-changes mailing list