BIND 10 trac2219, updated. 01244a662e1ad9387e27c2f5e1723c954d47a12b [2219] cover a minor case: zone finder's getOrigin() with non absolute label.

BIND 10 source code commits bind10-changes at lists.isc.org
Sat Sep 22 05:57:09 UTC 2012


The branch, trac2219 has been updated
       via  01244a662e1ad9387e27c2f5e1723c954d47a12b (commit)
      from  97e21bca2ddfc0ceb7350b741efae2c4199383ad (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 01244a662e1ad9387e27c2f5e1723c954d47a12b
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Fri Sep 21 22:53:35 2012 -0700

    [2219] cover a minor case: zone finder's getOrigin() with non absolute label.

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

Summary of changes:
 src/lib/datasrc/memory/zone_finder.cc              |   23 ++++++++++++++++++++
 src/lib/datasrc/memory/zone_finder.h               |    4 +---
 .../datasrc/tests/memory/zone_finder_unittest.cc   |    7 ++++++
 3 files changed, 31 insertions(+), 3 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/zone_finder.cc b/src/lib/datasrc/memory/zone_finder.cc
index 7472e32..50460d3 100644
--- a/src/lib/datasrc/memory/zone_finder.cc
+++ b/src/lib/datasrc/memory/zone_finder.cc
@@ -768,6 +768,29 @@ InMemoryZoneFinder::findNSEC3(const isc::dns::Name& name, bool recursive) {
               << getClass());
 }
 
+Name
+InMemoryZoneFinder::getOrigin() const {
+    size_t data_len;
+    const uint8_t* data;
+
+    // Normally the label sequence of the origin node should be absolute,
+    // in which case we can simply generate the origin name from the labels.
+    const LabelSequence node_labels = zone_data_.getOriginNode()->getLabels();
+    if (node_labels.isAbsolute()) {
+        data = node_labels.getData(&data_len);
+    } else {
+        // If and when we allow non absolute label at the origin (e.g. for
+        // the convenience of out-of-zone glue handling), we first need to
+        // construct the absolute label sequence and then construct the name.
+        uint8_t labels_buf[LabelSequence::MAX_SERIALIZED_LENGTH];
+        const LabelSequence name_labels =
+            zone_data_.getOriginNode()->getAbsoluteLabels(labels_buf);
+        data = name_labels.getData(&data_len);
+    }
+    util::InputBuffer buffer(data, data_len);
+    return (Name(buffer));
+}
+
 } // namespace memory
 } // namespace datasrc
 } // namespace isc
diff --git a/src/lib/datasrc/memory/zone_finder.h b/src/lib/datasrc/memory/zone_finder.h
index 603d633..3ac6729 100644
--- a/src/lib/datasrc/memory/zone_finder.h
+++ b/src/lib/datasrc/memory/zone_finder.h
@@ -99,9 +99,7 @@ public:
     findNSEC3(const isc::dns::Name& name, bool recursive);
 
     /// \brief Returns the origin of the zone.
-    virtual isc::dns::Name getOrigin() const {
-        return (zone_data_.getOriginNode()->getName());
-    }
+    virtual isc::dns::Name getOrigin() const;
 
     /// \brief Returns the RR class of the zone.
     virtual isc::dns::RRClass getClass() const {
diff --git a/src/lib/datasrc/tests/memory/zone_finder_unittest.cc b/src/lib/datasrc/tests/memory/zone_finder_unittest.cc
index df19d0a..a121b96 100644
--- a/src/lib/datasrc/tests/memory/zone_finder_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_finder_unittest.cc
@@ -557,6 +557,13 @@ public:
  */
 TEST_F(InMemoryZoneFinderTest, constructor) {
     ASSERT_EQ(origin_, zone_finder_.getOrigin());
+
+    // Some unusual (abnormal case): if we add a super domain name of the
+    // zone somehow, the label of the origin node won't be absolute.
+    // getOrigin() should still be the correct one.
+    ZoneNode *node;
+    zone_data_->insertName(mem_sgmt_, Name("org"), &node);
+    ASSERT_EQ(origin_, zone_finder_.getOrigin());
 }
 
 TEST_F(InMemoryZoneFinderTest, findCNAME) {



More information about the bind10-changes mailing list