Browse Source

[2165] Ignore RRSIG database records if sigs argument is false

This avoids some more processing if RRSIGs are not requested.

DatabaseClientTest.invalidRdata was adjusted to call find() with
ZoneFinder::FIND_DNSSEC because the invalid RDATA was in the RRSIG.
Mukund Sivaraman 12 years ago
parent
commit
3c20e037be
2 changed files with 10 additions and 4 deletions
  1. 6 2
      src/lib/datasrc/database.cc
  2. 4 2
      src/lib/datasrc/tests/database_unittest.cc

+ 6 - 2
src/lib/datasrc/database.cc

@@ -173,6 +173,10 @@ public:
         }
     }
 
+    bool empty() const {
+        return (sigs_.empty());
+    }
+
 private:
     std::map<isc::dns::RRType, std::vector<isc::dns::rdata::RdataPtr> > sigs_;
 };
@@ -214,7 +218,7 @@ DatabaseClient::Finder::getRRsets(const string& name, const WantedTypes& types,
         try {
             const RRType cur_type(columns[DatabaseAccessor::TYPE_COLUMN]);
 
-            if (cur_type == RRType::RRSIG()) {
+            if (sigs && (cur_type == RRType::RRSIG())) {
                 // If we get signatures before we get the actual data, we
                 // can't know which ones to keep and which to drop...
                 // So we keep a separate store of any signature that may be
@@ -277,7 +281,7 @@ DatabaseClient::Finder::getRRsets(const string& name, const WantedTypes& types,
         isc_throw(DataSourceError, "CNAME shares domain " << name <<
                   " with something else");
     }
-    if (sigs) {
+    if (!sig_store.empty()) {
         // Add signatures to all found RRsets
         for (std::map<RRType, RRsetPtr>::iterator i(result.begin());
              i != result.end(); ++ i) {

+ 4 - 2
src/lib/datasrc/tests/database_unittest.cc

@@ -3641,9 +3641,11 @@ TYPED_TEST(DatabaseClientTest, compoundUpdate) {
 TYPED_TEST(DatabaseClientTest, invalidRdata) {
     boost::shared_ptr<DatabaseClient::Finder> finder(this->getFinder());
 
-    EXPECT_THROW(finder->find(Name("invalidrdata.example.org."), RRType::A()),
+    EXPECT_THROW(finder->find(Name("invalidrdata.example.org."),
+                              RRType::A()),
                  DataSourceError);
-    EXPECT_THROW(finder->find(Name("invalidrdata2.example.org."), RRType::A()),
+    EXPECT_THROW(finder->find(Name("invalidrdata2.example.org."),
+                              RRType::A(), ZoneFinder::FIND_DNSSEC),
                  DataSourceError);
 }