From f772bb061324e41a41f037b4779830a6d6a02675 Mon Sep 17 00:00:00 2001 From: Otto Date: Fri, 5 Feb 2021 16:18:55 +0100 Subject: [PATCH] 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... (cherry picked from commit 558d47eba7d2edd3fb5991af428d9d432fec1dfa) --- pdns/lua-recursor4.cc | 2 +- pdns/pdns_recursor.cc | 8 ++++---- pdns/syncres.hh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index 1bfb865eeb..b6b30c2295 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -658,7 +658,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 99a1952068..a20a47b6cc 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1164,7 +1164,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; @@ -1179,10 +1179,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)); @@ -1508,7 +1508,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 80a2e6dc86..3b91b35b82 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -1109,7 +1109,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); -- 2.47.2