Browse Source

[2218] Check that the NSEC3 tree has nodes before performing findNSEC3()

Mukund Sivaraman 12 years ago
parent
commit
3ef4699944
1 changed files with 8 additions and 2 deletions
  1. 8 2
      src/lib/datasrc/memory/zone_finder.cc

+ 8 - 2
src/lib/datasrc/memory/zone_finder.cc

@@ -645,6 +645,14 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
                   getOrigin() << "/" << getClass());
     }
 
+    const NSEC3Data* nsec3_data = zone_data_.getNSEC3Data();
+    const ZoneTree& tree = nsec3_data->getNSEC3Tree();
+    if (tree.getNodeCount() == 0) {
+        isc_throw(DataSourceError,
+                  "findNSEC3 attempt but zone has no NSEC3 RR: " <<
+                  getOrigin() << "/" << getClass());
+    }
+
     const NameComparisonResult cmp_result = name.compare(getOrigin());
     if (cmp_result.getRelation() != NameComparisonResult::EQUAL &&
         cmp_result.getRelation() != NameComparisonResult::SUBDOMAIN) {
@@ -656,12 +664,10 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
     // Convenient shortcuts
     const unsigned int olabels = getOrigin().getLabelCount();
     const unsigned int qlabels = name.getLabelCount();
-    const NSEC3Data* nsec3_data = zone_data_.getNSEC3Data();
 
     // placeholder of the next closer proof
     const ZoneNode* covering_node(NULL);
 
-    const ZoneTree& tree = nsec3_data->getNSEC3Tree();
     ZoneChain chain;
 
     // Examine all names from the query name to the origin name, stripping