From: Otto Date: Fri, 5 Feb 2021 15:18:55 +0000 (+0100) Subject: Return current rcode instead of 0 if there are no CNAME records to follow. X-Git-Tag: dnsdist-1.6.0-alpha2~54^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F10064%2Fhead;p=thirdparty%2Fpdns.git Return current rcode instead of 0 if there are no CNAME records to follow. Note that this is a change in behaviour. While it is for the good, it might be existing code depends on the old 0 value... --- diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index 2e742cd549..d2f57f7918 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -664,7 +664,7 @@ loop:; if(!dq.followupFunction.empty()) { if(dq.followupFunction=="followCNAMERecords") { - ret = followCNAMERecords(dq.records, QType(dq.qtype)); + ret = followCNAMERecords(dq.records, QType(dq.qtype), ret); } else if(dq.followupFunction=="getFakeAAAARecords") { ret=getFakeAAAARecords(dq.followupName, ComboAddress(dq.followupPrefix), dq.records); diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 66fc158d2f..3e4348caff 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1352,7 +1352,7 @@ static bool udrCheckUniqueDNSRecord(const DNSName& dname, uint16_t qtype, const } #endif /* NOD_ENABLED */ -int followCNAMERecords(vector& ret, const QType& qtype) +int followCNAMERecords(vector& ret, const QType& qtype, int rcode) { vector resolved; DNSName target; @@ -1367,10 +1367,10 @@ int followCNAMERecords(vector& ret, const QType& qtype) } if(target.empty()) { - return 0; + return rcode; } - int rcode = directResolve(target, qtype, QClass::IN, resolved); + rcode = directResolve(target, qtype, QClass::IN, resolved); for(DNSRecord& rr : resolved) { ret.push_back(std::move(rr)); @@ -1691,7 +1691,7 @@ static void startDoResolve(void *p) ret = std::move(dc->d_records); res = *dc->d_rcode; if (res == RCode::NoError && dc->d_followCNAMERecords) { - res = followCNAMERecords(ret, QType(dc->d_mdp.d_qtype)); + res = followCNAMERecords(ret, QType(dc->d_mdp.d_qtype), res); } goto haveAnswer; } diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 2a7c8d9d61..5bb8821ae5 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -1094,7 +1094,7 @@ void broadcastFunction(const pipefunc_t& func); void distributeAsyncFunction(const std::string& question, const pipefunc_t& func); int directResolve(const DNSName& qname, const QType& qtype, int qclass, vector& ret); -int followCNAMERecords(std::vector& ret, const QType& qtype); +int followCNAMERecords(std::vector& ret, const QType& qtype, int oldret); int getFakeAAAARecords(const DNSName& qname, ComboAddress prefix, vector& ret); int getFakePTRRecords(const DNSName& qname, vector& ret);