]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
layer/iterate: imprevements in unhelpfull referral processing
authorGrigorii Demidov <grigorii.demidov@nic.cz>
Tue, 21 Mar 2017 11:48:07 +0000 (12:48 +0100)
committerGrigorii Demidov <grigorii.demidov@nic.cz>
Tue, 21 Mar 2017 11:48:07 +0000 (12:48 +0100)
lib/layer/iterate.c

index 6e97d6f9c0a04e8fa4dc66c8c091205ed3cf5f80..c6c768033cc59b16c105af5ba1c8b0ced4f07a84 100644 (file)
@@ -326,10 +326,12 @@ static int process_authority(knot_pkt_t *pkt, struct kr_request *req)
 #endif
        /* Remember current bailiwick for NS processing. */
        const knot_dname_t *current_zone_cut = qry->zone_cut.name;
+       bool authority_record_exist = false;
        /* Update zone cut information. */
        for (unsigned i = 0; i < ns->count; ++i) {
                const knot_rrset_t *rr = knot_pkt_rr(ns, i);
                if (rr->type == KNOT_RRTYPE_NS) {
+                       authority_record_exist = true;
                        int state = update_cut(pkt, rr, req, current_zone_cut);
                        switch(state) {
                        case KR_STATE_DONE: result = state; break;
@@ -343,8 +345,11 @@ static int process_authority(knot_pkt_t *pkt, struct kr_request *req)
        }
 
        if ((qry->flags & QUERY_DNSSEC_WANT) && (result == KR_STATE_CONSUME)) {
-               if (knot_wire_get_aa(pkt->wire) == 0 && knot_wire_get_ancount(pkt->wire) == 0) {
-                       /* Prevent from validating as an autoritative answer */
+               if (knot_wire_get_aa(pkt->wire) == 0 &&
+                   knot_wire_get_ancount(pkt->wire) == 0 &&
+                   authority_record_exist) {
+                       /* Unhelpful referral
+                          Prevent from validating as an authoritative answer */
                        result = KR_STATE_DONE;
                }
        }