Browse Source

[trac553] Cancel wildcard at empty existing domain

We check to see if there's an empty non-terminal domain before check for
wildcard. If it is detected, there exists a subdomain and therefore we
should not do a wildcard check.
Michal 'vorner' Vaner 14 years ago
parent
commit
6fbb0f720f
1 changed files with 14 additions and 8 deletions
  1. 14 8
      src/lib/datasrc/memory_datasrc.cc

+ 14 - 8
src/lib/datasrc/memory_datasrc.cc

@@ -416,8 +416,22 @@ struct MemoryZone::MemoryZoneImpl {
                     return (FindResult(DELEGATION, prepareRRset(name,
                         state.rrset_, rename)));
                 }
+
+                // If the RBTree search stopped at a node for a super domain
+                // of the search name, it means the search name exists in
+                // the zone but is empty.  Treat it as NXRRSET.
+                if (node_path.getLastComparisonResult().getRelation() ==
+                    NameComparisonResult::SUPERDOMAIN) {
+                    return (FindResult(NXRRSET, ConstRRsetPtr()));
+                }
+
                 /*
                  * No redirection anywhere. Let's try if it is a wildcard.
+                 *
+                 * The wildcard is checked after the empty non-terminal domain
+                 * case above, because if that one triggers, it means we should
+                 * not match according to 4.3.3 of RFC 1034 (the query name
+                 * is known to exist).
                  */
                 if (node->getFlag(DOMAINFLAG_WILD)) {
                     Name wildcard(Name("*").concatenate(
@@ -438,14 +452,6 @@ struct MemoryZone::MemoryZoneImpl {
                     break;
                 }
 
-                // If the RBTree search stopped at a node for a super domain
-                // of the search name, it means the search name exists in
-                // the zone but is empty.  Treat it as NXRRSET.
-                if (node_path.getLastComparisonResult().getRelation() ==
-                    NameComparisonResult::SUPERDOMAIN) {
-                    return (FindResult(NXRRSET, ConstRRsetPtr()));
-                }
-
                 // fall through
             case DomainTree::NOTFOUND:
                 return (FindResult(NXDOMAIN, ConstRRsetPtr()));