From: Vladimír Čunát Date: Mon, 20 Feb 2017 12:50:39 +0000 (+0100) Subject: iterate: skip answer RRs that don't match the query X-Git-Tag: v1.3.0~23^2~74^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09bb0d037f3e7fbe22f58f35be1877d4f16cb8c8;p=thirdparty%2Fknot-resolver.git iterate: skip answer RRs that don't match the query Fixes https://gitlab.labs.nic.cz/knot/resolver/issues/160 --- diff --git a/lib/layer/iterate.c b/lib/layer/iterate.c index 9ca26a04a..1b9a702c9 100644 --- a/lib/layer/iterate.c +++ b/lib/layer/iterate.c @@ -391,9 +391,18 @@ static int unroll_cname(knot_pkt_t *pkt, struct kr_request *req, bool referral, pending_cname = NULL; for (unsigned i = 0; i < an->count; ++i) { const knot_rrset_t *rr = knot_pkt_rr(an, i); - if (!knot_dname_is_equal(rr->owner, cname)) { + + /* Skip the RR if its owner+type doesn't interest us. */ + const bool type_OK = rr->type == query->stype + || rr->type == KNOT_RRTYPE_CNAME + || rr->type == KNOT_RRTYPE_DNAME /* TODO: actually handle it */ + || (rr->type == KNOT_RRTYPE_RRSIG + && knot_rrsig_type_covered(&rr->rrs, 0)) + ; + if (!type_OK || !knot_dname_is_equal(rr->owner, cname)) { continue; } + /* Process records matching current SNAME */ int state = KR_STATE_FAIL; bool to_wire = false;