]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix one potential issue spotted by Coverity 15573/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 20 May 2025 08:09:09 +0000 (10:09 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 20 May 2025 08:09:09 +0000 (10:09 +0200)
As spotted by Coverity, one function called from a destructor could
in theory throw an exception which is not caught from within the
destructor, which would lead to a termination of the program.
At a quick glance it seems quite impossible to happen in practice
with the current code, but let's fix it nevertheless.

pdns/dnsdistdist/dnsdist-tcp.cc

index 266b72477e8c21559969b575746482619b443d4f..5bf74c2693e716f51a504ab6cff314394536cc52 100644 (file)
@@ -65,7 +65,12 @@ std::atomic<uint64_t> g_tcpStatesDumpRequested{0};
 
 IncomingTCPConnectionState::~IncomingTCPConnectionState()
 {
-  dnsdist::IncomingConcurrentTCPConnectionsManager::accountClosedTCPConnection(d_ci.remote);
+  try {
+    dnsdist::IncomingConcurrentTCPConnectionsManager::accountClosedTCPConnection(d_ci.remote);
+  }
+  catch (...) {
+    /* in theory it might raise an exception, and we cannot allow it to be uncaught in a dtor */
+  }
 
   if (d_ci.cs != nullptr) {
     timeval now{};