Browse Source

[2124] Don't catch InvalidBufferPosition when parsing wiredata

Mukund Sivaraman 12 years ago
parent
commit
2c8689536e
2 changed files with 9 additions and 14 deletions
  1. 6 11
      src/lib/dns/rdata/generic/sshfp_44.cc
  2. 3 3
      src/lib/dns/tests/rdata_sshfp_unittest.cc

+ 6 - 11
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);
     }
 }
 

+ 3 - 3
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) {