From 475fc44ee8d1fc21bb9fe0beffa5fd5b1799277f Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Wed, 3 Apr 2019 14:10:22 +0200 Subject: [PATCH] A way to fix https://github.com/PowerDNS/pdns/issues/7646. It might not be the right place, though, but it prevents fatal exception on unparseable A (or AAAA) addresss for nameserver addresses needed to send notifies. --- pdns/communicator.hh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pdns/communicator.hh b/pdns/communicator.hh index 5413e4dacf23..2cb0f70feb3c 100644 --- a/pdns/communicator.hh +++ b/pdns/communicator.hh @@ -259,10 +259,25 @@ public: 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) - addresses.push_back(rr.dr.d_content->getZoneRepresentation()); // SOL if you have a CNAME for an NS + bool ok; + do { + DNSZoneRecord rr; + try { + ok = b->get(rr); + } + catch (PDNSException &ae) { + g_log << Logger::Error << "Skipping record: " << ae.reason << endl; + continue; + } + catch (std::exception &e) { + g_log << Logger::Error << "Skipping record: " << e.what() << endl; + continue; + } + if (ok) { + 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 + } + } while (ok); } return addresses; }