]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Avoid throwing an exception in Logger::log(). 9079/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 1 May 2020 08:56:09 +0000 (10:56 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 1 May 2020 08:56:09 +0000 (10:56 +0200)
Throwing an exception in the logger, almost cetainly will cause
trouble. Coverity 1428667 shows this can happen in
LdapBackend::~LdapBackend().

pdns/logger.cc
pdns/logger.hh

index 61dcf28f5fe9d61b153d716f1038e762c4315217..6804b3997959e6b72eff16601cda998f0a48cb1b 100644 (file)
@@ -50,7 +50,7 @@ Logger& getLogger()
   return log;
 }
 
-void Logger::log(const string &msg, Urgency u)
+void Logger::log(const string &msg, Urgency u) noexcept
 {
 #ifndef RECURSOR
   bool mustAccount(false);
@@ -113,8 +113,14 @@ void Logger::log(const string &msg, Urgency u)
   }
 
 #ifndef RECURSOR
-  if(mustAccount)
-    S.ringAccount("logmessages",msg);
+  if(mustAccount) {
+      try {
+        S.ringAccount("logmessages",msg);
+      }
+      catch (const runtime_error& e) {
+        cerr << e.what() << endl;
+      }
+  }
 #endif
 }
 
index 38689e2d5a88b16c51141cd84640c671b9110175..e8c4da7019f769c779d354f0d8377f87e5c18666 100644 (file)
@@ -45,7 +45,7 @@ public:
       \param msg Message you wish to log
       \param u Urgency of the message you wish to log
   */
-  void log(const string &msg, Urgency u=Notice);
+  void log(const string &msg, Urgency u=Notice) noexcept;
 
   void setFacility(int f){d_facility=f;open();} //!< Choose logging facility
   void setFlag(int f){flags|=f;open();} //!< set a syslog flag