]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2420] catch the rare case of RRSIG-only for NSEC3
authorJINMEI Tatuya <jinmei@isc.org>
Tue, 13 Nov 2012 01:48:33 +0000 (17:48 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Tue, 13 Nov 2012 01:50:07 +0000 (17:50 -0800)
src/lib/datasrc/memory/zone_finder.cc
src/lib/datasrc/tests/memory/zone_finder_unittest.cc

index f6a5c8d2aa3f5219a23e34b6d5619c078f948606..4240c21d6304a0123cd65fcf716dfecf44fdd110 100644 (file)
@@ -216,6 +216,14 @@ createNSEC3RRset(const ZoneNode* node, const RRClass& rrclass) {
      assert(rdataset != NULL);
      assert(rdataset->type == RRType::NSEC3());
 
+     // Check for the rare case of RRSIG-only record; in theory it could exist
+     // but we simply consider it broken for NSEC3.
+     if (rdataset->getRdataCount() == 0) {
+         uint8_t labels_buf[LabelSequence::MAX_SERIALIZED_LENGTH];
+         isc_throw(DataSourceError, "Broken zone: RRSIG-only NSEC3 record at "
+                   << node->getAbsoluteLabels(labels_buf) << "/" << rrclass);
+     }
+
     // Create the RRset.  Note the DNSSEC flag: NSEC3 implies DNSSEC.
     return (createTreeNodeRRset(node, rdataset, rrclass,
                                 ZoneFinder::FIND_DNSSEC));
index 3df1179885730d6a1558d5250fa84c042231347a..f1121194ea1596b680d6c158118b821fd35f7473 100644 (file)
@@ -1549,4 +1549,17 @@ TEST_F(InMemoryZoneFinderNSEC3Test, findNSEC3Walk) {
         }
     }
 }
+
+TEST_F(InMemoryZoneFinderNSEC3Test, RRSIGOnly) {
+    // add an RRSIG-only NSEC3 to the NSEC3 space, and try to find it; it
+    // should result in an exception.
+    const string n8_hash = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
+    updater_.add(ConstRRsetPtr(),
+                 textToRRset(
+                     n8_hash + ".example.org. 300 IN RRSIG NSEC3 5 3 300 "
+                     "20120814220826 20120715220826 1234 example.com. FAKE"));
+    EXPECT_THROW(zone_finder_.findNSEC3(Name("n8.example.org"), false),
+                 DataSourceError);
+}
+
 }