Browse Source

[trac505] Don't fail on too long synthesized names

Return YXDOMAIN instead.
Michal 'vorner' Vaner 14 years ago
parent
commit
f998d61387
1 changed files with 22 additions and 10 deletions
  1. 22 10
      src/bin/auth/query.cc

+ 22 - 10
src/bin/auth/query.cc

@@ -177,16 +177,28 @@ Query::process() const {
                 // by that)
                 RRsetPtr cname(new RRset(qname_, rrset->getClass(),
                     RRType::CNAME(), rrset->getTTL()));
-                // Construct the new target by replacing the end
-                cname->addRdata(rdata::generic::CNAME(qname_.split(0,
-                    qname_.getLabelCount() -
-                    rrset->getName().getLabelCount()).concatenate(
-                    dname.getDname())));
-                rrset = cname;
-                // If this was ANY, act as it wasn't, because we put the CNAME
-                // into rrset, not to target and there's nothing else.
-                // TODO: This might need to be changed when CNAME gets chaining.
-                qtype_is_any = false;
+                try {
+                    // Construct the new target by replacing the end
+                    cname->addRdata(rdata::generic::CNAME(qname_.split(0,
+                        qname_.getLabelCount() -
+                        rrset->getName().getLabelCount()).concatenate(
+                        dname.getDname())));
+                    rrset = cname;
+                    // If this was ANY, act as it wasn't, because we put the
+                    // CNAME into rrset, not to target and there's nothing else.
+                    // TODO: This might need to be changed when CNAME gets
+                    // chaining.
+                    qtype_is_any = false;
+                }
+                /*
+                 * 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());
+                    getAuthAdditional(*result.zone);
+                    return;
+                }
                 // No break; here, fall trough.
             }
             case Zone::CNAME: