aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-09-27 14:58:55 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-09-27 17:28:47 +0000
commit661439f4e057f06cd637bd5d467ef70f213755aa (patch)
treeb7c08122a98647fe6efd036286cdd4e2660923e7
parenteasylogging++: test for NULL before dereference (diff)
downloadmonero-661439f4e057f06cd637bd5d467ef70f213755aa.tar.xz
mlog: don't remove old logs if we failed to rename the current file
Coverity 188348
-rw-r--r--contrib/epee/src/mlog.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp
index cd9867ff5..61d853ef4 100644
--- a/contrib/epee/src/mlog.cpp
+++ b/contrib/epee/src/mlog.cpp
@@ -137,7 +137,12 @@ void mlog_configure(const std::string &filename_base, bool console, const std::s
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
el::Helpers::installPreRollOutCallback([filename_base, max_log_files](const char *name, size_t){
std::string rname = generate_log_filename(filename_base.c_str());
- rename(name, rname.c_str());
+ int ret = rename(name, rname.c_str());
+ if (ret < 0)
+ {
+ // can't log a failure, but don't do the file removal below
+ return;
+ }
if (max_log_files != 0)
{
std::vector<boost::filesystem::path> found_files;