]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
secpoll: set to unknown when OK before throwing
authorPieter Lexis <pieter.lexis@powerdns.com>
Mon, 24 Jun 2019 14:06:24 +0000 (16:06 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 24 Jun 2019 14:06:24 +0000 (16:06 +0200)
pdns/secpoll.cc

index e919623bad6600e8265abbdad8dd04d455024d3b..31299d7c0a1c9e10a3339291770ed5d39f7b8b47 100644 (file)
@@ -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<DNSRecord> &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<DNSRecord> &ret, int &secPo
   }
 
   if (record.d_name.empty()) {
+    setSecPollToUnknownOnOK(secPollStatus);
     throw PDNSException("No TXT record found in response");
   }
 
   auto recordContent = getRR<TXTRecordContent>(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<DNSRecord> &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;