From 0d757bd2ccf0150e69ae630fdc1f78e998114205 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 17 Jul 2023 12:19:11 +0200 Subject: [PATCH] auth: Fix 'exceptions not caught' warnings from Coverity --- pdns/auth-main.cc | 28 +++++++++++++++++++++------- pdns/dnssecinfra.cc | 3 ++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pdns/auth-main.cc b/pdns/auth-main.cc index 38d81c56aa..c28931fe3f 100644 --- a/pdns/auth-main.cc +++ b/pdns/auth-main.cc @@ -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 (...) { diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index 3e9056d711..9024b04502 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -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 -- 2.47.2