Browse Source

[2420] make sure RRSIG-only data are excluded in additional processing

JINMEI Tatuya 12 years ago
parent
commit
f7e29b8836

+ 4 - 1
src/lib/datasrc/memory/zone_finder.cc

@@ -627,7 +627,10 @@ private:
             // This can be a bit more optimized, but unless we have many
             // This can be a bit more optimized, but unless we have many
             // requested types the effect is probably marginal.  For now we
             // requested types the effect is probably marginal.  For now we
             // keep it simple.
             // keep it simple.
-            if (std::find(type_beg, type_end, rdset->type) != type_end) {
+            // Check for getRdataCount is necessary not to include RRSIG-only
+            // records accidentally (should be rare, but possible).
+            if (std::find(type_beg, type_end, rdset->type) != type_end &&
+                rdset->getRdataCount() > 0) {
                 result->push_back(createTreeNodeRRset(node, rdset, rrclass_,
                 result->push_back(createTreeNodeRRset(node, rdset, rrclass_,
                                                       options, real_name));
                                                       options, real_name));
             }
             }

+ 7 - 0
src/lib/datasrc/tests/testdata/contexttest.zone

@@ -68,6 +68,13 @@ e.example.org. 	      	      3600 IN NS	ns2.example.org.
 *.wild.example.org.	      3600 IN A		192.0.2.15
 *.wild.example.org.	      3600 IN A		192.0.2.15
 a.*.emptywild.example.org.    3600 IN AAAA	2001:db8::2
 a.*.emptywild.example.org.    3600 IN AAAA	2001:db8::2
 
 
+;; One of the additional records actually only has RRSIG, which should
+;; be ignored.
+f.example.org. 	      	      3600 IN MX 5 mx1.f.example.org.
+f.example.org. 	      	      3600 IN MX 10 mx2.f.example.org.
+mx1.f.example.org.     	      3600 IN RRSIG A 5 3 3600 20150420235959 20051021000000 40430 example.org. FAKEFAKE
+mx2.f.example.org.     	      3600 IN A 192.0.2.16
+
 ;; additional for an answer RRset (MX) as a result of wildcard
 ;; additional for an answer RRset (MX) as a result of wildcard
 ;; expansion
 ;; expansion
 *.wildmx.example.org. 3600 IN MX 1 mx1.example.org.
 *.wildmx.example.org. 3600 IN MX 1 mx1.example.org.

+ 12 - 0
src/lib/datasrc/tests/zone_finder_context_unittest.cc

@@ -418,4 +418,16 @@ TEST_P(ZoneFinderContextTest, getAdditionalForAny) {
                 result_sets_.begin(), result_sets_.end());
                 result_sets_.begin(), result_sets_.end());
 }
 }
 
 
+TEST_P(ZoneFinderContextTest, getAdditionalWithRRSIGOnly) {
+    // This has two MX records, but type-A for one of them only has RRSIG.
+    // It shouldn't be contained in the result.
+    ZoneFinderContextPtr ctx = finder_->find(Name("f.example.org"),
+                                             RRType::MX(),
+                                             ZoneFinder::FIND_DNSSEC);
+    EXPECT_EQ(ZoneFinder::SUCCESS, ctx->code);
+    ctx->getAdditional(REQUESTED_BOTH, result_sets_);
+    rrsetsCheck("mx2.f.example.org. 3600 IN A 192.0.2.16\n",
+                result_sets_.begin(), result_sets_.end());
+}
+
 }
 }