]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1483] Protect the method by exception
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Tue, 13 Dec 2011 13:22:09 +0000 (14:22 +0100)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Tue, 13 Dec 2011 13:22:09 +0000 (14:22 +0100)
src/lib/datasrc/database.cc
src/lib/datasrc/tests/database_unittest.cc

index 33aa2b9eb413eb4708864202482616ed7cda9be0..7c09df8fa38c217c8cdffb36dafe5e393509ede0 100644 (file)
@@ -410,6 +410,9 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
                              const isc::dns::RRType& type,
                              const FindOptions options)
 {
+    if (type == RRType::ANY()) {
+        isc_throw(isc::Unexpected, "Use findAll to answer ANY");
+    }
     return (findInternal(name, type, NULL, options));
 }
 
index 4f4af273406bcb6eb38f0479cd84fbcc5d04d58e..9fc4cf35f2e19a429918006d7659405bb5d39262 100644 (file)
@@ -2287,6 +2287,12 @@ TYPED_TEST(DatabaseClientTest, emptyNonterminalNSEC) {
                                Name::ROOT_NAME(), ZoneFinder::FIND_DNSSEC));
 }
 
+TYPED_TEST(DatabaseClientTest, anyFromFind) {
+    // Find will reject answering an ANY query
+    EXPECT_THROW(this->getFinder()->find(isc::dns::Name("www2.example.org."),
+                                         RRType::ANY()), isc::Unexpected);
+}
+
 // Test the findAll method.
 TYPED_TEST(DatabaseClientTest, getAll) {
     // The domain doesn't exist, so we must get the right NSEC