]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2377] Reject load incremental of 0 RRs
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Mon, 10 Dec 2012 12:26:05 +0000 (13:26 +0100)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Mon, 10 Dec 2012 12:26:05 +0000 (13:26 +0100)
As it makes little sense.

src/lib/dns/master_loader.cc
src/lib/dns/tests/master_loader_unittest.cc

index 8b91dd7c0610f72f941b3889cb970b42ced3e8e4..bc1b4d12312d06b19f8d2cd1ef624d7c5cca0bcb 100644 (file)
@@ -108,6 +108,9 @@ public:
 
 bool
 MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
+    if (count_limit == 0) {
+        isc_throw(isc::InvalidParameter, "Count limit set to 0");
+    }
     if (complete_) {
         isc_throw(isc::InvalidOperation,
                   "Trying to load when already loaded");
index fea7664236197bd2895edf52d36bd86cc0f5e7cd..4ac124d2ce11c33cf77c75847457436d846a5c94 100644 (file)
@@ -299,4 +299,12 @@ TEST_F(MasterLoaderTest, loadTwice) {
     loader_->load();
     EXPECT_THROW(loader_->load(), isc::InvalidOperation);
 }
+
+// Load 0 items should be rejected
+TEST_F(MasterLoaderTest, loadZero) {
+    setLoader(TEST_DATA_SRCDIR "/example.org", Name("example.org."),
+              RRClass::IN(), MasterLoader::MANY_ERRORS);
+    EXPECT_THROW(loader_->loadIncremental(0), isc::InvalidParameter);
+}
+
 }