]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
iterate: skip answer RRs that don't match the query
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 20 Feb 2017 12:50:39 +0000 (13:50 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 20 Feb 2017 14:08:12 +0000 (15:08 +0100)
Fixes https://gitlab.labs.nic.cz/knot/resolver/issues/160

lib/layer/iterate.c

index 9ca26a04ae0b2250d7d5c566fcd31419d81cd86a..1b9a702c93e0a7b944194697649fef172f4fe91e 100644 (file)
@@ -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;