BIND 10 trac2108_3, updated. 0f8bc280b95e71f7b5095dea586c84868c852d7c [2108] Untabify code

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Sep 7 04:05:32 UTC 2012


The branch, trac2108_3 has been updated
       via  0f8bc280b95e71f7b5095dea586c84868c852d7c (commit)
       via  11fbb68418d52e4ac94ebbb8297013336e54779c (commit)
      from  35057f3b488579a7ad147c18ae20581ca5866eda (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0f8bc280b95e71f7b5095dea586c84868c852d7c
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Sep 7 09:35:22 2012 +0530

    [2108] Untabify code

commit 11fbb68418d52e4ac94ebbb8297013336e54779c
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Sep 7 09:35:14 2012 +0530

    [2108] Loading an empty zone without even an SOA for the origin should throw

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/memory/memory_client.cc            |   12 ++++++++++--
 src/lib/datasrc/memory/memory_client.h             |   12 +++++++++++-
 .../datasrc/memory/tests/memory_client_unittest.cc |   10 ++++++++++
 src/lib/datasrc/memory/tests/testdata/Makefile.am  |    3 ++-
 .../lib/datasrc/memory/tests/testdata/empty.zone   |    0
 5 files changed, 33 insertions(+), 4 deletions(-)
 copy NEWS => src/lib/datasrc/memory/tests/testdata/empty.zone (100%)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/memory_client.cc b/src/lib/datasrc/memory/memory_client.cc
index 3a2f633..3a00894 100644
--- a/src/lib/datasrc/memory/memory_client.cc
+++ b/src/lib/datasrc/memory/memory_client.cc
@@ -561,19 +561,27 @@ InMemoryClient::InMemoryClientImpl::load(
 
     assert(!last_rrset_);
 
+    const ZoneNode* origin_node = holder.get()->getOriginNode();
+    const RdataSet* set = origin_node->getData();
     // If the zone is NSEC3-signed, check if it has NSEC3PARAM
     if (holder.get()->isNSEC3Signed()) {
         // Note: origin_data_ is set on creation of ZoneData, and the load
         // process only adds new nodes (and their data), so this assertion
         // should hold.
-        const ZoneNode* origin_node = holder.get()->getOriginNode();
-        const RdataSet* set = origin_node->getData();
         if (RdataSet::find(set, RRType::NSEC3PARAM()) == NULL) {
             LOG_WARN(logger, DATASRC_MEM_NO_NSEC3PARAM).
                 arg(zone_name).arg(rrclass_);
         }
     }
 
+    // When an empty zone file is loaded, the origin doesn't even have
+    // an SOA RR. This condition should be avoided, and hence load()
+    // should throw when an empty zone is loaded.
+    if (RdataSet::find(set, RRType::SOA()) == NULL) {
+        isc_throw(EmptyZone,
+                  "Won't create an empty zone for: " << zone_name);
+    }
+
     LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_ADD_ZONE).
         arg(zone_name).arg(rrclass_.toText());
 
diff --git a/src/lib/datasrc/memory/memory_client.h b/src/lib/datasrc/memory/memory_client.h
index a965f5e..0c211c1 100644
--- a/src/lib/datasrc/memory/memory_client.h
+++ b/src/lib/datasrc/memory/memory_client.h
@@ -123,7 +123,7 @@ public:
     /// have to be revisited fundamentally, and at that point this restriction
     /// probably won't matter.
     result::Result load(const isc::dns::Name& zone_name,
-			ZoneIterator& iterator);
+                        ZoneIterator& iterator);
 
     /// Return the master file name of the zone
     ///
@@ -177,6 +177,16 @@ public:
         { }
     };
 
+    /// \brief Zone is empty exception.
+    ///
+    /// This is thrown if we have an empty zone created as a result of
+    /// load().
+    struct EmptyZone : public InvalidParameter {
+        EmptyZone(const char* file, size_t line, const char* what) :
+            InvalidParameter(file, line, what)
+        { }
+    };
+
     /// \brief General failure exception for \c add().
     ///
     /// This is thrown against general error cases in adding an RRset
diff --git a/src/lib/datasrc/memory/tests/memory_client_unittest.cc b/src/lib/datasrc/memory/tests/memory_client_unittest.cc
index da82a92..41ff923 100644
--- a/src/lib/datasrc/memory/tests/memory_client_unittest.cc
+++ b/src/lib/datasrc/memory/tests/memory_client_unittest.cc
@@ -119,6 +119,16 @@ TEST_F(MemoryClientTest, loadNonExistentZoneFile) {
     // Teardown checks for memory segment leaks
 }
 
+TEST_F(MemoryClientTest, loadEmptyZoneFileThrows) {
+    // When an empty zone file is loaded, the origin doesn't even have
+    // an SOA RR. This condition should be avoided, and hence load()
+    // should throw when an empty zone is loaded.
+    EXPECT_THROW(client_->load(Name("."),
+                               TEST_DATA_DIR "/empty.zone"),
+                 InMemoryClient::EmptyZone);
+    // Teardown checks for memory segment leaks
+}
+
 TEST_F(MemoryClientTest, load) {
     // This is a simple load check for a "full" and correct zone that
     // should not result in any exceptions.
diff --git a/src/lib/datasrc/memory/tests/testdata/Makefile.am b/src/lib/datasrc/memory/tests/testdata/Makefile.am
index 2a551e8..4ef70a5 100644
--- a/src/lib/datasrc/memory/tests/testdata/Makefile.am
+++ b/src/lib/datasrc/memory/tests/testdata/Makefile.am
@@ -1,6 +1,7 @@
 CLEANFILES = *.copied
 
-EXTRA_DIST =  example.org.zone
+EXTRA_DIST =  empty.zone
+EXTRA_DIST += example.org.zone
 EXTRA_DIST += example.org-empty.zone
 EXTRA_DIST += example.org-broken1.zone
 EXTRA_DIST += example.org-broken2.zone
diff --git a/src/lib/datasrc/memory/tests/testdata/empty.zone b/src/lib/datasrc/memory/tests/testdata/empty.zone
new file mode 100644
index 0000000..e69de29



More information about the bind10-changes mailing list