From: Remi Gacogne Date: Mon, 3 Apr 2017 08:53:41 +0000 (+0200) Subject: rec: Fix cache-only queries against a forward-zone X-Git-Tag: rec-4.0.5-rc1~1^2~7^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e660e9f681cf2548498cd550b23d45b19e0ba47;p=pdns rec: Fix cache-only queries against a forward-zone We used to pass the return code from `asyncresolve` directly to the caller, leading the success code (1) to be interpreted as `RCode::FormErr`. (cherry picked from commit 6148fa9731f6e4cef35243c8f35399d2b1e89215) --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 11f35b0ff..6f16f3406 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -439,15 +439,19 @@ int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vector nm; + boost::optional nm; res=asyncresolveWrapper(remoteIP, d_doDNSSEC, qname, qtype.getCode(), false, false, &d_now, nm, &lwr); // filter out the good stuff from lwr.result() - - for(const auto& rec : lwr.d_records) { - if(rec.d_place == DNSResourceRecord::ANSWER) - ret.push_back(rec); + if (res == 1) { + for(const auto& rec : lwr.d_records) { + if(rec.d_place == DNSResourceRecord::ANSWER) + ret.push_back(rec); + } + return 0; + } + else { + return RCode::ServFail; } - return res; } } }