BIND 10 trac505, updated. 073d75e7ab64ff107198181cbc9ef4482e83b681 [trac505] FIXME: Replace assert

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Feb 10 09:28:04 UTC 2011


The branch, trac505 has been updated
       via  073d75e7ab64ff107198181cbc9ef4482e83b681 (commit)
       via  4fd542a1c095efee2afb61c440784cd3984803cc (commit)
       via  5400e06818b54c363c6006395ea51567caa651b3 (commit)
       via  746980b33112b63147744796663389e5e1c3144c (commit)
      from  0b1f8cb6dfa5481cb67e43ee8c2f24fac97ec95d (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 073d75e7ab64ff107198181cbc9ef4482e83b681
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Thu Feb 10 10:25:48 2011 +0100

    [trac505] FIXME: Replace assert

commit 4fd542a1c095efee2afb61c440784cd3984803cc
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Thu Feb 10 10:25:27 2011 +0100

    [trac505] Style: Brace position

commit 5400e06818b54c363c6006395ea51567caa651b3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Thu Feb 10 10:21:45 2011 +0100

    [trac505] Check the length manually

commit 746980b33112b63147744796663389e5e1c3144c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Thu Feb 10 10:07:38 2011 +0100

    [trac505] More comments

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

Summary of changes:
 src/bin/auth/query.cc                |   38 ++++++++++++++++++++-------------
 src/bin/auth/tests/query_unittest.cc |   10 +++-----
 2 files changed, 27 insertions(+), 21 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/auth/query.cc b/src/bin/auth/query.cc
index a5d15d9..3b98746 100644
--- a/src/bin/auth/query.cc
+++ b/src/bin/auth/query.cc
@@ -156,34 +156,42 @@ Query::process() const {
                 /*
                  * Empty DNAME should never get in, as it is impossible to
                  * create one in master file.
+                 *
+                 * FIXME: Other way to prevent this should be done
                  */
                 assert(db_result.rrset->getRdataCount() > 0);
                 // Get the data of DNAME
                 const rdata::generic::DNAME& dname(
                     dynamic_cast<const rdata::generic::DNAME&>(
                     db_result.rrset->getRdataIterator()->getCurrent()));
-                // The new CNAME we are creating (it will be unsigned even
-                // with DNSSEC, the DNAME is signed and it can be validated
-                // by that)
-                RRsetPtr cname(new RRset(qname_, db_result.rrset->getClass(),
-                    RRType::CNAME(), db_result.rrset->getTTL()));
-                try {
-                    // Construct the new target by replacing the end
-                    cname->addRdata(rdata::generic::CNAME(qname_.split(0,
-                        qname_.getLabelCount() -
-                        db_result.rrset->getName().getLabelCount()).
-                        concatenate(dname.getDname())));
-                    response_.addRRset(Message::SECTION_ANSWER, cname);
-                    break;
-                }
+                // The yet unmatched prefix dname
+                Name prefix(qname_.split(0, qname_.getLabelCount() -
+                    db_result.rrset->getName().getLabelCount()));
+                // If we put it together, will it be too long?
+                // (The prefix contains trailing ., which will be removed
+                if (prefix.getLength() - Name(".").getLength() +
+                    dname.getDname().getLength() > Name::MAX_WIRE ||
+                    prefix.getLabelCount() - Name(".").getLabelCount() +
+                    dname.getDname().getLabelCount() > Name::MAX_LABELS) {
                 /*
                  * In case the synthetized name is too long, section 4.1 of RFC
                  * 2672 mandates we return YXDOMAIN.
                  */
-                catch (const isc::dns::TooLongName&) {
                     response_.setRcode(Rcode::YXDOMAIN());
                     return;
                 }
+                // The new CNAME we are creating (it will be unsigned even
+                // with DNSSEC, the DNAME is signed and it can be validated
+                // by that)
+                RRsetPtr cname(new RRset(qname_, db_result.rrset->getClass(),
+                RRType::CNAME(), db_result.rrset->getTTL()));
+                // Construct the new target by replacing the end
+                cname->addRdata(rdata::generic::CNAME(qname_.split(0,
+                    qname_.getLabelCount() -
+                    db_result.rrset->getName().getLabelCount()).
+                    concatenate(dname.getDname())));
+                response_.addRRset(Message::SECTION_ANSWER, cname);
+                break;
             }
             case Zone::CNAME:
                 /*
diff --git a/src/bin/auth/tests/query_unittest.cc b/src/bin/auth/tests/query_unittest.cc
index d391d5d..ced47fe 100644
--- a/src/bin/auth/tests/query_unittest.cc
+++ b/src/bin/auth/tests/query_unittest.cc
@@ -145,13 +145,13 @@ private:
             rrset->getType() == RRType::NS()) {
             delegation_rrset_ = rrset;
         } else if (rrset->getName() == dname_name_ &&
-            rrset->getType() == RRType::DNAME())
-        {
+            rrset->getType() == RRType::DNAME()) {
             dname_rrset_ = rrset;
         }
     }
 
     const Name origin_;
+    // Names where we delegate somewhere else
     const Name delegation_name_;
     const Name dname_name_;
     bool has_SOA_;
@@ -181,8 +181,7 @@ MockZone::find(const Name& name, const RRType& type,
         return (FindResult(DELEGATION, delegation_rrset_));
     // And under DNAME
     } else if (name.compare(dname_name_).getRelation() ==
-        NameComparisonResult::SUBDOMAIN)
-    {
+        NameComparisonResult::SUBDOMAIN) {
         return (FindResult(DNAME, dname_rrset_));
     }
 
@@ -200,8 +199,7 @@ MockZone::find(const Name& name, const RRType& type,
         // If not found but we have a target, fill it with all RRsets here
         if (!found_domain->second.empty() && target != NULL) {
             for (found_rrset = found_domain->second.begin();
-                 found_rrset != found_domain->second.end(); found_rrset++)
-            {
+                 found_rrset != found_domain->second.end(); found_rrset++) {
                 // Insert RRs under the domain name into target
                 target->addRRset(
                     boost::const_pointer_cast<RRset>(found_rrset->second));




More information about the bind10-changes mailing list