BIND 10 trac2108_3, updated. e898d07a4540cc9783779f0f39ddcf8264419068 [2108] Add CNAME+other tests (which should throw)

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Sep 10 04:08:14 UTC 2012


The branch, trac2108_3 has been updated
       via  e898d07a4540cc9783779f0f39ddcf8264419068 (commit)
       via  083e6836264daff5da8aa95dff7927d0f37f0e43 (commit)
       via  3f0eb8fec78587398baa9964c344330b77a37f9e (commit)
      from  41eff487aee5315bdb63b805d1e3e9efe13118f4 (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 e898d07a4540cc9783779f0f39ddcf8264419068
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Sep 10 09:37:55 2012 +0530

    [2108] Add CNAME+other tests (which should throw)

commit 083e6836264daff5da8aa95dff7927d0f37f0e43
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Sep 10 09:37:26 2012 +0530

    [2108] Fix context check when adding a CNAME record

commit 3f0eb8fec78587398baa9964c344330b77a37f9e
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Sep 10 09:36:53 2012 +0530

    [2108] If there's an exception, clear last_rrset_

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

Summary of changes:
 src/lib/datasrc/memory/memory_client.cc            |   28 +++++++++++++-------
 .../datasrc/memory/tests/memory_client_unittest.cc |   15 +++++++++++
 src/lib/datasrc/memory/tests/testdata/Makefile.am  |    5 ++--
 .../testdata/example.org-cname-and-not-nsec-1.zone |    4 +++
 .../testdata/example.org-cname-and-not-nsec-2.zone |    4 +++
 5 files changed, 44 insertions(+), 12 deletions(-)
 create mode 100644 src/lib/datasrc/memory/tests/testdata/example.org-cname-and-not-nsec-1.zone
 create mode 100644 src/lib/datasrc/memory/tests/testdata/example.org-cname-and-not-nsec-2.zone

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/memory_client.cc b/src/lib/datasrc/memory/memory_client.cc
index fb2a8e2..e21fd48 100644
--- a/src/lib/datasrc/memory/memory_client.cc
+++ b/src/lib/datasrc/memory/memory_client.cc
@@ -178,11 +178,14 @@ public:
         // owner name except with NSEC, which is the only RR that can coexist
         // with CNAME (and also RRSIG, which is handled separately)
         if (rrset.getType() == RRType::CNAME()) {
-            if (RdataSet::find(set, RRType::NSEC()) != NULL) {
-                LOG_ERROR(logger, DATASRC_MEM_CNAME_TO_NONEMPTY).
-                    arg(rrset.getName());
-                isc_throw(AddError, "CNAME can't be added with other data for "
-                          << rrset.getName());
+            for (const RdataSet* sp = set; sp != NULL; sp = sp->getNext()) {
+                if (sp->type != RRType::NSEC()) {
+                    LOG_ERROR(logger, DATASRC_MEM_CNAME_TO_NONEMPTY).
+                        arg(rrset.getName());
+                    isc_throw(AddError, "CNAME can't be added with "
+                              << sp->type << " RRType for "
+                              << rrset.getName());
+                }
             }
         } else if ((rrset.getType() != RRType::NSEC()) &&
                    (RdataSet::find(set, RRType::CNAME()) != NULL)) {
@@ -548,11 +551,16 @@ InMemoryClient::InMemoryClientImpl::load(
 
     assert(!last_rrset_);
 
-    rrset_installer(boost::bind(&InMemoryClientImpl::addFromLoad, this,
-                                _1, zone_name, holder.get()));
-
-    // Add any last RRset that was left
-    addRdataSet(zone_name, *holder.get(), ConstRRsetPtr(), ConstRRsetPtr());
+    try {
+        rrset_installer(boost::bind(&InMemoryClientImpl::addFromLoad, this,
+                                    _1, zone_name, holder.get()));
+        // Add any last RRset that was left
+        addRdataSet(zone_name, *holder.get(),
+                    ConstRRsetPtr(), ConstRRsetPtr());
+    } catch (...) {
+        last_rrset_ = ConstRRsetPtr();
+        throw;
+    }
 
     assert(!last_rrset_);
 
diff --git a/src/lib/datasrc/memory/tests/memory_client_unittest.cc b/src/lib/datasrc/memory/tests/memory_client_unittest.cc
index 032b965..e16431b 100644
--- a/src/lib/datasrc/memory/tests/memory_client_unittest.cc
+++ b/src/lib/datasrc/memory/tests/memory_client_unittest.cc
@@ -335,6 +335,21 @@ TEST_F(MemoryClientTest, loadNSEC3WithMoreLabelsThrows) {
     // Teardown checks for memory segment leaks
 }
 
+TEST_F(MemoryClientTest, loadCNAMEAndNotNSECThrows) {
+    // CNAME and not NSEC should throw
+    EXPECT_THROW(client_->load(Name("example.org"),
+                               TEST_DATA_DIR
+                               "/example.org-cname-and-not-nsec-1.zone"),
+                 InMemoryClient::AddError);
+
+    EXPECT_THROW(client_->load(Name("example.org"),
+                               TEST_DATA_DIR
+                               "/example.org-cname-and-not-nsec-2.zone"),
+                 InMemoryClient::AddError);
+
+    // Teardown checks for memory segment leaks
+}
+
 TEST_F(MemoryClientTest, loadRRSIGFollowsNothing) {
     EXPECT_THROW(client_->load(Name("example.org"),
                                TEST_DATA_DIR
diff --git a/src/lib/datasrc/memory/tests/testdata/Makefile.am b/src/lib/datasrc/memory/tests/testdata/Makefile.am
index 721448a..23429a4 100644
--- a/src/lib/datasrc/memory/tests/testdata/Makefile.am
+++ b/src/lib/datasrc/memory/tests/testdata/Makefile.am
@@ -21,5 +21,6 @@ EXTRA_DIST += example.org-out-of-zone.zone
 EXTRA_DIST += example.org-wildcard-ns.zone
 EXTRA_DIST += example.org-wildcard-dname.zone
 EXTRA_DIST += example.org-wildcard-nsec3.zone
-EXTRA_DIST += example.org-nsec3-fewer-labels.zone
-EXTRA_DIST += example.org-nsec3-more-labels.zone
+EXTRA_DIST += example.org-nsec3-fewer-labels.zone example.org-nsec3-more-labels.zone
+EXTRA_DIST += example.org-cname-and-not-nsec-1.zone
+EXTRA_DIST += example.org-cname-and-not-nsec-2.zone
diff --git a/src/lib/datasrc/memory/tests/testdata/example.org-cname-and-not-nsec-1.zone b/src/lib/datasrc/memory/tests/testdata/example.org-cname-and-not-nsec-1.zone
new file mode 100644
index 0000000..d44762d
--- /dev/null
+++ b/src/lib/datasrc/memory/tests/testdata/example.org-cname-and-not-nsec-1.zone
@@ -0,0 +1,4 @@
+;; NSEC3 names with labels != (origin_labels + 1)
+example.org.				      86400 IN SOA	ns.example.org. ns.example.org. 2012091009 7200 3600 2592000 1200
+a.example.org.				      7200  IN A	192.168.0.1
+a.example.org.				      3600  IN CNAME	foo.example.com.
diff --git a/src/lib/datasrc/memory/tests/testdata/example.org-cname-and-not-nsec-2.zone b/src/lib/datasrc/memory/tests/testdata/example.org-cname-and-not-nsec-2.zone
new file mode 100644
index 0000000..bca72cb
--- /dev/null
+++ b/src/lib/datasrc/memory/tests/testdata/example.org-cname-and-not-nsec-2.zone
@@ -0,0 +1,4 @@
+;; NSEC3 names with labels != (origin_labels + 1)
+example.org.				      86400 IN SOA	ns.example.org. ns.example.org. 2012091007 7200 3600 2592000 1200
+a.example.org.				      3600  IN CNAME	foo.example.com.
+a.example.org.				      7200  IN A	192.168.0.1



More information about the bind10-changes mailing list