From: Daniel Salzman Date: Fri, 21 May 2021 11:23:28 +0000 (+0200) Subject: nameserver: correct owner of answered CNAME from wildcard expansion X-Git-Tag: v3.1.0~98^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e57e99fe7ebb0ab448ffda8fe4ec04c5da969a51;p=thirdparty%2Fknot-dns.git nameserver: correct owner of answered CNAME from wildcard expansion fixes #715 --- diff --git a/src/knot/nameserver/process_query.c b/src/knot/nameserver/process_query.c index 03a8152b56..87da3b2884 100644 --- a/src/knot/nameserver/process_query.c +++ b/src/knot/nameserver/process_query.c @@ -883,8 +883,8 @@ int process_query_put_rr(knot_pkt_t *pkt, knotd_qdata_t *qdata, /* Wildcard expansion applies only for answers. */ bool expand = false; if (pkt->current == KNOT_ANSWER) { - /* Expand if RR is wildcard & we didn't query for wildcard. */ - expand = (knot_dname_is_wildcard(rr->owner) && !knot_dname_is_wildcard(qdata->name)); + /* Expand if RR is wildcard. TRICK: if the asterix node is queried directly, we behave like if wildcard would be expanded. It's the same. */ + expand = knot_dname_is_wildcard(rr->owner); } int ret = KNOT_EOK; diff --git a/tests-extra/data/flags.zone b/tests-extra/data/flags.zone index a243803189..92b6970007 100644 --- a/tests-extra/data/flags.zone +++ b/tests-extra/data/flags.zone @@ -104,6 +104,10 @@ sub.*.wildcard A 6.7.8.9 ; Wildcard to CNAME *.wildcard-cname CNAME cname +; CNAME to asterix-leading expansion +wild-cname CNAME *.expanded.wildcard-cname2 +*.wildcard-cname2 CNAME *.expanded.wildcard-cname + ; Wildcard to delegation *.wildcard-deleg CNAME cname-ns diff --git a/tests-extra/tests/basic/query/test.py b/tests-extra/tests/basic/query/test.py index 4543d74601..19f8c96312 100644 --- a/tests-extra/tests/basic/query/test.py +++ b/tests-extra/tests/basic/query/test.py @@ -304,6 +304,14 @@ def query_test(knot, bind, dnssec): else: resp.cmp(bind, additional=True) + # Wildcard CNAME with asterisk query + resp = knot.dig("*.a.wildcard-cname.flags", "A", udp=True) + resp.cmp(bind) + + # Double wildcard expansion + resp = knot.dig("wild-cname.flags", "TXT", udp=True) + resp.cmp(bind) + # Wildcard leading out resp = knot.dig("a.wildcard-out.flags", "A", udp=True, dnssec=dnssec) resp.cmp(bind)