From: Remi Gacogne Date: Mon, 17 Jul 2023 10:19:11 +0000 (+0200) Subject: auth: Fix 'exceptions not caught' warnings from Coverity X-Git-Tag: rec-5.0.0-alpha1~98^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F13041%2Fhead;p=thirdparty%2Fpdns.git auth: Fix 'exceptions not caught' warnings from Coverity --- 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