From: Pieter Lexis Date: Mon, 24 Jun 2019 14:06:24 +0000 (+0200) Subject: secpoll: set to unknown when OK before throwing X-Git-Tag: dnsdist-1.4.0-rc1~93^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a4fd2ec233898a447739e48dd16d06bc982ceda3;p=thirdparty%2Fpdns.git secpoll: set to unknown when OK before throwing --- diff --git a/pdns/secpoll.cc b/pdns/secpoll.cc index e919623bad..31299d7c0a 100644 --- a/pdns/secpoll.cc +++ b/pdns/secpoll.cc @@ -30,11 +30,15 @@ bool isReleaseVersion(const std::string &version) { return std::count(version.begin(), version.end(), '.') == 2; } +void setSecPollToUnknownOnOK(int &secPollStatus) { + if(secPollStatus == 1) // it was ok, now it is unknown + secPollStatus = 0; +} + void processSecPoll(const int res, const std::vector &ret, int &secPollStatus, std::string &secPollMessage) { secPollMessage.clear(); if (res != 0) { // not NOERROR - if(secPollStatus == 1) // it was ok, now it is unknown - secPollStatus = 0; + setSecPollToUnknownOnOK(secPollStatus); throw PDNSException("RCODE was not NOERROR but " + RCode::to_s(res)); } @@ -53,11 +57,13 @@ void processSecPoll(const int res, const std::vector &ret, int &secPo } if (record.d_name.empty()) { + setSecPollToUnknownOnOK(secPollStatus); throw PDNSException("No TXT record found in response"); } auto recordContent = getRR(record); if (recordContent == nullptr) { + setSecPollToUnknownOnOK(secPollStatus); throw PDNSException("Could not parse TXT record content"); } string content = recordContent->d_text; @@ -67,6 +73,7 @@ void processSecPoll(const int res, const std::vector &ret, int &secPo try { secPollStatus = std::stoi(split.first); } catch (const std::exception &e) { + setSecPollToUnknownOnOK(secPollStatus); throw PDNSException(std::string("Could not parse status number: ") + e.what()); } secPollMessage = split.second;