From: Marek VavruĊĦa Date: Sat, 27 Jun 2015 23:26:48 +0000 (+0200) Subject: layer/iterate: don't update cut if we get m10n referral/CNAME X-Git-Tag: v1.0.0-beta1~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6c5f41d5bfa2a3cf3c291f47f1c4a5ea4dbbe86;p=thirdparty%2Fknot-resolver.git layer/iterate: don't update cut if we get m10n referral/CNAME --- diff --git a/lib/layer/iterate.c b/lib/layer/iterate.c index 260ce0462..a4e56357f 100644 --- a/lib/layer/iterate.c +++ b/lib/layer/iterate.c @@ -248,6 +248,15 @@ static int process_authority(knot_pkt_t *pkt, struct kr_request *req) } #endif + /* Work around servers sending back CNAME with different delegation and no AA. */ + const knot_pktsection_t *an = knot_pkt_section(pkt, KNOT_ANSWER); + if (an->count > 0 && ns->count > 0) { + const knot_rrset_t *rr = knot_pkt_rr(an, 0); + if (rr->type == KNOT_RRTYPE_CNAME) { + return KNOT_STATE_CONSUME; + } + } + /* Update zone cut information. */ for (unsigned i = 0; i < ns->count; ++i) { const knot_rrset_t *rr = knot_pkt_rr(ns, i); @@ -261,16 +270,6 @@ static int process_authority(knot_pkt_t *pkt, struct kr_request *req) } } - /* Work around servers sending back CNAME with different delegation and no AA. */ - const knot_pktsection_t *an = knot_pkt_section(pkt, KNOT_ANSWER); - if (result == KNOT_STATE_DONE && an->count > 0) { - const knot_rrset_t *rr = knot_pkt_rr(an, 0); - if (rr->type == KNOT_RRTYPE_CNAME) { - DEBUG_MSG("<= different delegation, but has a CNAME answer\n"); - result = KNOT_STATE_CONSUME; - } - } - /* CONSUME => Unhelpful referral. * DONE => Zone cut updated. */ return result; diff --git a/tests/testdata/iter_minim_nonempty.rpl b/tests/testdata/iter_minim_nonempty.rpl index 44e88349c..464934480 100644 --- a/tests/testdata/iter_minim_nonempty.rpl +++ b/tests/testdata/iter_minim_nonempty.rpl @@ -85,9 +85,12 @@ REPLY AA QR NOERROR SECTION QUESTION example.com. IN NS SECTION ANSWER -example.com. IN CNAME nowhere. +example.com. IN CNAME nowhere.cdn.example.com. SECTION AUTHORITY -com. IN NS a.gtld-servers.net. +; Suggest authority of 'nowhere' (which must not be followed) +cdn.example.com. IN NS ns01.cdn.example.com. +SECTION ADDITIONAL +ns01.cdn.example.com. IN A 1.1.1.1 ENTRY_END ENTRY_BEGIN