From 2b062ae29bbc86008899c05e807fd9096ed9720d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 10 Aug 2017 00:33:24 +0200 Subject: tp in daemon mode with syslog used the wrong name Need to keep the string given to openlog() alive while syslog is used or it will use random other memory in that location --- src/logger.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/logger.cc') diff --git a/src/logger.cc b/src/logger.cc index e04b588..da097a1 100644 --- a/src/logger.cc +++ b/src/logger.cc @@ -40,8 +40,9 @@ public: class LoggerSyslog : public Logger { public: - LoggerSyslog(std::string const& name) { - openlog(name.c_str(), LOG_PID, LOG_DAEMON); + LoggerSyslog(std::string const& name) + : name_(name) { + openlog(name_.c_str(), LOG_PID, LOG_DAEMON); } ~LoggerSyslog() override { @@ -75,6 +76,9 @@ private: assert(false); return LOG_INFO; } + + // Copy of name to keep pointer alive while syslog has access to it + std::string const name_; }; class LoggerFile : public Logger { -- cgit v1.2.3-70-g09d2