diff options
author | Daniel Salzman <daniel.salzman@nic.cz> | 2016-10-24 19:10:10 +0200 |
---|---|---|
committer | Daniel Salzman <daniel.salzman@nic.cz> | 2016-10-25 14:20:58 +0200 |
commit | 59d110fc4fb8ea26d842789f65ca5c381b5b2d91 (patch) | |
tree | cbd30a8122b1364dfc9438b9382e97c82e4c3ee6 | |
parent | Merge branch 'qp-coverity' into 'master' (diff) | |
download | knot-59d110fc4fb8ea26d842789f65ca5c381b5b2d91.tar.xz knot-59d110fc4fb8ea26d842789f65ca5c381b5b2d91.zip |
internet: skip empty non-terminal parents during delegation lookup
-rw-r--r-- | src/knot/nameserver/internet.c | 11 | ||||
-rw-r--r-- | tests-extra/data/flags.zone | 3 | ||||
-rw-r--r-- | tests-extra/tests/basic/query/test.py | 5 |
3 files changed, 16 insertions, 3 deletions
diff --git a/src/knot/nameserver/internet.c b/src/knot/nameserver/internet.c index 1269eb57a..f796ae738 100644 --- a/src/knot/nameserver/internet.c +++ b/src/knot/nameserver/internet.c @@ -454,9 +454,16 @@ static int name_not_found(knot_pkt_t *pkt, struct query_data *qdata) return follow_cname(pkt, KNOT_RRTYPE_DNAME, qdata); } + /* Look up an authoritative encloser or its parent. */ + const zone_node_t *node = qdata->encloser; + while (node->rrset_count == 0 || node->flags & NODE_FLAGS_NONAUTH) { + node = node->parent; + assert(node); + } + /* Name is below delegation. */ - if ((qdata->encloser->flags & NODE_FLAGS_DELEG)) { - qdata->node = qdata->encloser; + if ((node->flags & NODE_FLAGS_DELEG)) { + qdata->node = node; return DELEG; } diff --git a/tests-extra/data/flags.zone b/tests-extra/data/flags.zone index a71811e1a..5bc42585e 100644 --- a/tests-extra/data/flags.zone +++ b/tests-extra/data/flags.zone @@ -19,6 +19,8 @@ mail A 192.0.2.3 ; Delegation of a subdomain sub NS ns.sub +sub NS sub +sub A 192.0.0.1 ns.sub A 192.0.2.4 ; CNAME to A record @@ -56,7 +58,6 @@ cname-mx-wc MX 10 cname-wildcard ; MX record leading to CNAME (outside zone) cname-mx-out MX 10 cname-out - ; DNAME subtree dname DNAME dname-tree dname-tree A 1.2.3.4 diff --git a/tests-extra/tests/basic/query/test.py b/tests-extra/tests/basic/query/test.py index 86e0c2dbb..89a430eef 100644 --- a/tests-extra/tests/basic/query/test.py +++ b/tests-extra/tests/basic/query/test.py @@ -56,6 +56,11 @@ resp = knot.dig("ns.sub.flags", "A", udp=True) resp.check(rcode="NOERROR", flags="QR", noflags="AA TC AD RA") resp.cmp(bind, additional=True) +# Positive (REFERRAL, below delegation, ignoring empty-nonterminal during lookup) +resp = knot.dig("bellow.ns.sub.flags", "A", udp=True) +resp.check(rcode="NOERROR", flags="QR", noflags="AA TC AD RA") +resp.cmp(bind, additional=True) + ''' ANY query type. ''' # ANY to SOA record |