]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2435] Don't throw in case of out of zone queries
authorMukund Sivaraman <muks@isc.org>
Wed, 9 Jan 2013 05:53:47 +0000 (11:23 +0530)
committerMukund Sivaraman <muks@isc.org>
Wed, 9 Jan 2013 05:53:47 +0000 (11:23 +0530)
src/lib/datasrc/rrset_collection.cc
src/lib/datasrc/tests/database_unittest.cc

index e4cfd8801556be734a2f31344aae5a5750b50e28..ffe102e11bd441f5be39ac4169686233d053a3ae 100644 (file)
@@ -35,11 +35,17 @@ RRsetCollection::find(const isc::dns::Name& name,
     }
 
     ZoneFinder& finder = updater_->getFinder();
-    ZoneFinderContextPtr result =
-        finder.find(name, rrtype,
-                    ZoneFinder::NO_WILDCARD | ZoneFinder::FIND_GLUE_OK);
-
-    return (result->rrset);
+    try {
+        ZoneFinderContextPtr result =
+            finder.find(name, rrtype,
+                        ZoneFinder::NO_WILDCARD | ZoneFinder::FIND_GLUE_OK);
+        return (result->rrset);
+    } catch (const OutOfZone&) {
+        // As RRsetCollection is an arbitrary set of RRsets, in case the
+        // searched name is out of zone, we return nothing instead of
+        // propagating the exception.
+        return (ConstRRsetPtr());
+    }
 }
 
 RRsetCollectionBase::IterPtr
index 39729f8d27d967b93a28597253fc85a066d4f03a..5b19ace9438ce79dc42577b4c3e4b814f95129e9 100644 (file)
@@ -4198,6 +4198,11 @@ TYPED_TEST(RRsetCollectionTest, find) {
     rrset = this->collection.find(Name("www.example.org"), RRClass::CH(),
                                   RRType::AAAA());
     EXPECT_FALSE(rrset);
+
+    // Out of zone find()s must not throw.
+    rrset = this->collection.find(Name("www.example.com"), this->qclass_,
+                                  RRType::A());
+    EXPECT_FALSE(rrset);
 }
 
 TYPED_TEST(RRsetCollectionTest, iteratorTest) {