From 2c75693e72abe792e0bf9b55c5f8f443fa220160 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Wed, 3 Apr 2019 14:10:22 +0200 Subject: [PATCH] Fix fatal exception on unparseable slave addresses. Backport of https://github.com/PowerDNS/pdns/pull/7662 --- pdns/communicator.hh | 24 +++++++++++++++++++----- pdns/mastercommunicator.cc | 2 +- pdns/tcpreceiver.cc | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/pdns/communicator.hh b/pdns/communicator.hh index a7f95b81d..f646b2226 100644 --- a/pdns/communicator.hh +++ b/pdns/communicator.hh @@ -244,18 +244,32 @@ private: class FindNS { public: - vector lookup(const DNSName &name, UeberBackend *b) + vector lookup(const DNSName &name, UeberBackend *b, const DNSName& zone) { vector addresses; this->resolve_name(&addresses, name); if(b) { - b->lookup(QType(QType::ANY),name); - DNSZoneRecord rr; - while(b->get(rr)) - if(rr.dr.d_type == QType::A || rr.dr.d_type==QType::AAAA) + b->lookup(QType(QType::ANY),name); + while (true) { + try { + DNSZoneRecord rr; + if (!b->get(rr)) + break; + if (rr.dr.d_type == QType::A || rr.dr.d_type == QType::AAAA) addresses.push_back(rr.dr.d_content->getZoneRepresentation()); // SOL if you have a CNAME for an NS + } + // After an exception, b can be inconsistent so break + catch (PDNSException &ae) { + L << Logger::Error << "Could not lookup address for nameserver " << name << " in zone " << zone << ", cannot notify: " << ae.reason << endl; + break; + } + catch (std::exception &e) { + L << Logger::Error << "Could not lookup address for nameserver " << name << " in zone " << zone << ", cannot notify: " << e.what() << endl; + break; + } + } } return addresses; } diff --git a/pdns/mastercommunicator.cc b/pdns/mastercommunicator.cc index 456957a80..8be9ebad9 100644 --- a/pdns/mastercommunicator.cc +++ b/pdns/mastercommunicator.cc @@ -56,7 +56,7 @@ void CommunicatorClass::queueNotifyDomain(const DomainInfo& di, UeberBackend* B) nsset.insert(getRR(rr.dr)->getNS().toString()); for(set::const_iterator j=nsset.begin();j!=nsset.end();++j) { - vector nsips=fns.lookup(DNSName(*j), B); + vector nsips=fns.lookup(DNSName(*j), B, di.zone); if(nsips.empty()) L< q) while(B->get(rr)) nsset.insert(DNSName(rr.content)); for(const auto & j: nsset) { - vector nsips=fns.lookup(j, s_P->getBackend()); + vector nsips=fns.lookup(j, s_P->getBackend(),q->qdomain); for(vector::const_iterator k=nsips.begin();k!=nsips.end();++k) { // cerr<<"got "<<*k<<" from AUTO-NS"<getRemote().toString()) -- 2.40.0