From: Otto Moerbeek Date: Fri, 1 May 2020 08:56:09 +0000 (+0200) Subject: Avoid throwing an exception in Logger::log(). X-Git-Tag: dnsdist-1.5.0-rc2~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c3d0fb44481a973b9328546c5414637edff03e4f;p=thirdparty%2Fpdns.git Avoid throwing an exception in Logger::log(). Throwing an exception in the logger, almost cetainly will cause trouble. Coverity 1428667 shows this can happen in LdapBackend::~LdapBackend(). --- diff --git a/pdns/logger.cc b/pdns/logger.cc index 61dcf28f5f..6804b39979 100644 --- a/pdns/logger.cc +++ b/pdns/logger.cc @@ -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 } diff --git a/pdns/logger.hh b/pdns/logger.hh index 38689e2d5a..e8c4da7019 100644 --- a/pdns/logger.hh +++ b/pdns/logger.hh @@ -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