Parcourir la source

- use DNSMessageFORMERR exception type instead of InvalidRdata
- use an explicit long-long constant for the dnssectime overflow test


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1353 e5f2f494-b856-4b98-b285-d166d9295462

Evan Hunt il y a 15 ans
Parent
commit
c215be2ca4

+ 0 - 11
src/lib/dns/rdata.h

@@ -55,17 +55,6 @@ public:
 };
 
 ///
-/// \brief A standard DNS module exception that is thrown if wire format
-/// RDTA is invalid
-///
-class InvalidRdata : public Exception {
-public:
-    InvalidRdata(const char* file, size_t line, const char* what) :
-        isc::Exception(file, line, what) {}
-};
-
-
-///
 /// \brief A standard DNS module exception that is thrown if RDATA parser
 /// parser encounters a character-string (as defined in RFC1035) exceeding
 /// the maximum allowable length (\c MAX_CHARSTRING_LEN).

+ 5 - 2
src/lib/dns/rdata/generic/nsec3_50.cc

@@ -24,6 +24,7 @@
 
 #include "base32.h"
 #include "buffer.h"
+#include "exceptions.h"
 #include "hex.h"
 #include "messagerenderer.h"
 #include "name.h"
@@ -170,11 +171,13 @@ NSEC3::NSEC3(InputBuffer& buffer, size_t rdata_len)
     int len = 0;
     for (int i = 0; i < typebits.size(); i += len) {
         if (i + 2 > typebits.size()) {
-            isc_throw(InvalidRdata, "Bad NSEC3 typebits");
+            isc_throw(DNSMessageFORMERR, "Invalid rdata: "
+                                         "bad NSEC3 type bitmap");
         }
         len = typebits[i + 1];
         if (len > 31) {
-            isc_throw(InvalidRdata, "Bad NSEC3 typebits");
+            isc_throw(DNSMessageFORMERR, "Invalid rdata: "
+                                         "bad NSEC3 type bitmap");
         }
         i += 2;
     }

+ 5 - 2
src/lib/dns/rdata/generic/nsec_47.cc

@@ -23,6 +23,7 @@
 
 #include "base64.h"
 #include "buffer.h"
+#include "exceptions.h"
 #include "messagerenderer.h"
 #include "name.h"
 #include "rrtype.h"
@@ -110,11 +111,13 @@ NSEC::NSEC(InputBuffer& buffer, size_t rdata_len)
     int len = 0;
     for (int i = 0; i < typebits.size(); i += len) {
         if (i + 2 > typebits.size()) {
-            isc_throw(InvalidRdata, "Bad NSEC typebits");
+            isc_throw(DNSMessageFORMERR, "Invalid rdata: "
+                                         "bad NSEC type bitmap");
         }
         len = typebits[i + 1];
         if (len > 31) {
-            isc_throw(InvalidRdata, "Bad NSEC typebits");
+            isc_throw(DNSMessageFORMERR, "Invalid rdata: "
+                                         "bad NSEC type bitmap");
         }
         i += 2;
     }

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

@@ -63,6 +63,6 @@ TEST(DNSSECTimeTest, toText)
     EXPECT_EQ("20100311233000", timeToText(1268350200));
 
     // Jan 1, Year 10,000.  What should we do?
-    EXPECT_THROW(timeToText(253402300800), InvalidTime);
+    EXPECT_THROW(timeToText(253402300800LL), InvalidTime);
 }
 }

+ 2 - 1
src/lib/dns/tests/rdata_nsec3_unittest.cc

@@ -18,6 +18,7 @@
 
 #include <dns/base32.h>
 #include <dns/buffer.h>
+#include <dns/exceptions.h>
 #include <dns/hex.h>
 #include <dns/messagerenderer.h>
 #include <dns/rdata.h>
@@ -88,7 +89,7 @@ TEST_F(Rdata_NSEC3_Test, createFromWire)
     // Invalid type bits
     EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC3(), RRClass::IN(),
                                       "testdata/rdata_nsec3_fromWire3"),
-                 InvalidRdata);
+                 DNSMessageFORMERR);
 }
 
 TEST_F(Rdata_NSEC3_Test, toWireRenderer)

+ 2 - 1
src/lib/dns/tests/rdata_nsec_unittest.cc

@@ -17,6 +17,7 @@
 #include <string>
 
 #include <dns/buffer.h>
+#include <dns/exceptions.h>
 #include <dns/messagerenderer.h>
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
@@ -68,7 +69,7 @@ TEST_F(Rdata_NSEC_Test, createFromWire_NSEC)
 
     EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
                        "testdata/rdata_nsec_fromWire3"),
-                 InvalidRdata);
+                 DNSMessageFORMERR);
 }
 
 TEST_F(Rdata_NSEC_Test, toWireRenderer_NSEC)