From: Otto Moerbeek Date: Wed, 3 Apr 2019 14:00:12 +0000 (+0200) Subject: Rearrange; to avoid uninitialized var and bail out after exception, X-Git-Tag: rec-4.2.0-rc1~42^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb22b82e6e97374e0eadcc03c56dd8e7f1328bf3;p=thirdparty%2Fpdns.git Rearrange; to avoid uninitialized var and bail out after exception, b might be inconsistent in that case. --- diff --git a/pdns/communicator.hh b/pdns/communicator.hh index 2cb0f70feb..831b2cecf5 100644 --- a/pdns/communicator.hh +++ b/pdns/communicator.hh @@ -258,26 +258,25 @@ public: this->resolve_name(&addresses, name); if(b) { - b->lookup(QType(QType::ANY),name); - bool ok; - do { + b->lookup(QType(QType::ANY),name); + while (true) { + try { 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); + 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) { + g_log << Logger::Error << "Skipping record(s): " << ae.reason << endl; + break; + } + catch (std::exception &e) { + g_log << Logger::Error << "Skipping record(s): " << e.what() << endl; + break; + } + } } return addresses; }