Browse Source

[trac117] fixed a bug of from text factory: it rejected flags > 0xf (it should be > 0xff)

JINMEI Tatuya 14 years ago
parent
commit
b099d02835
2 changed files with 13 additions and 1 deletions
  1. 1 1
      src/lib/dns/rdata/generic/nsec3_50.cc
  2. 12 0
      src/lib/dns/tests/rdata_nsec3_unittest.cc

+ 1 - 1
src/lib/dns/rdata/generic/nsec3_50.cc

@@ -71,7 +71,7 @@ NSEC3::NSEC3(const string& nsec3_str) :
     if (iss.bad() || iss.fail()) {
         isc_throw(InvalidRdataText, "Invalid NSEC3 text: " << nsec3_str);
     }
-    if (hashalg > 0xf) {
+    if (hashalg > 0xff) {
         isc_throw(InvalidRdataText,
                   "NSEC3 hash algorithm out of range: " << hashalg);
     }

+ 12 - 0
src/lib/dns/tests/rdata_nsec3_unittest.cc

@@ -46,6 +46,18 @@ public:
     string nsec3_txt;
 };
 
+TEST_F(Rdata_NSEC3_Test, fromText) {
+    // A normal case: the test constructor should successfully parse the
+    // text and construct nsec3_txt.  It will be tested against the wire format
+    // representation in the createFromWire test.
+
+    // Numeric parameters have possible maximum values.  Unusual, but must
+    // be accepted.
+    EXPECT_NO_THROW(generic::NSEC3("255 255 65535 D399EAAB "
+                                   "H9RSFB7FPF2L8HG35CMPC765TDK23RP6 "
+                                   "NS SOA RRSIG DNSKEY NSEC3PARAM"));
+}
+
 TEST_F(Rdata_NSEC3_Test, toText) {
     const generic::NSEC3 rdata_nsec3(nsec3_txt);
     EXPECT_EQ(nsec3_txt, rdata_nsec3.toText());