]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Fix 'exceptions not caught' warnings from Coverity 13041/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 17 Jul 2023 10:19:11 +0000 (12:19 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 17 Jul 2023 12:05:22 +0000 (14:05 +0200)
pdns/auth-main.cc
pdns/dnssecinfra.cc

index 38d81c56aaedff03a9fb45bcb9940639b60d0089..c28931fe3f2b1b57a5e6ac862d189365e779d229 100644 (file)
@@ -1470,11 +1470,15 @@ int main(int argc, char** argv)
     g_log << Logger::Error << "Fatal error: " << A.reason << endl;
     exit(1);
   }
+  catch (const std::exception& e) {
+    g_log << Logger::Error << "Fatal error: " << e.what() << endl;
+    exit(1);
+  }
 
   try {
     declareStats();
   }
-  catch (PDNSException& PE) {
+  catch (const PDNSException& PE) {
     g_log << Logger::Error << "Exiting because: " << PE.reason << endl;
     exit(1);
   }
@@ -1487,14 +1491,24 @@ int main(int argc, char** argv)
   try {
     mainthread();
   }
-  catch (PDNSException& e) {
-    if (!::arg().mustDo("daemon"))
-      cerr << "Exiting because: " << e.reason << endl;
+  catch (const PDNSException& e) {
+    try {
+      if (!::arg().mustDo("daemon")) {
+        cerr << "Exiting because: " << e.reason << endl;
+      }
+    }
+    catch (const ArgException& A) {
+    }
     g_log << Logger::Error << "Exiting because: " << e.reason << endl;
   }
-  catch (std::exception& e) {
-    if (!::arg().mustDo("daemon"))
-      cerr << "Exiting because of STL error: " << e.what() << endl;
+  catch (const std::exception& e) {
+    try {
+      if (!::arg().mustDo("daemon")) {
+        cerr << "Exiting because of STL error: " << e.what() << endl;
+      }
+    }
+    catch (const ArgException& A) {
+    }
     g_log << Logger::Error << "Exiting because of STL error: " << e.what() << endl;
   }
   catch (...) {
index 3e9056d711368f5caae4d2551b1cc3d9b9aac66c..9024b04502637ef0dbe9af619a332b836ffa1b7f 100644 (file)
@@ -526,8 +526,9 @@ string getMessageForRRSET(const DNSName& qname, const RRSIGRecordContent& rrc, c
 
     if (rrsig_labels < fqdn_labels) {
       DNSName choppedQname(qname);
-      while (choppedQname.countLabels() > rrsig_labels)
+      while (choppedQname.countLabels() > rrsig_labels) {
         choppedQname.chopOff();
+      }
       nameToHash = "\x01*" + choppedQname.toDNSStringLC();
     } else if (rrsig_labels > fqdn_labels) {
       // The RRSIG Labels field is a lie (or the qname is wrong) and the RRSIG