diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-07-26 14:50:23 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-07-26 22:49:54 +0100 |
commit | 262e391fb168ce2ac5f41869125208526a811891 (patch) | |
tree | 2c2023c8e99a67b3fa3767f564a6a3c42a607574 /contrib/epee/src | |
parent | Merge pull request #4088 (diff) | |
download | monero-262e391fb168ce2ac5f41869125208526a811891.tar.xz |
mlog: handle filenames without parent directories
eg, --log-file=foo.log
This would otherwise throw and crash with a stack overflow
Diffstat (limited to '')
-rw-r--r-- | contrib/epee/src/mlog.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index e8248c958..818fc0a69 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -142,7 +142,9 @@ void mlog_configure(const std::string &filename_base, bool console, const std::s { std::vector<boost::filesystem::path> found_files; const boost::filesystem::directory_iterator end_itr; - for (boost::filesystem::directory_iterator iter(boost::filesystem::path(filename_base).parent_path()); iter != end_itr; ++iter) + const boost::filesystem::path filename_base_path(filename_base); + const boost::filesystem::path parent_path = filename_base_path.has_parent_path() ? filename_base_path.parent_path() : "."; + for (boost::filesystem::directory_iterator iter(parent_path); iter != end_itr; ++iter) { const std::string filename = iter->path().string(); if (filename.size() >= filename_base.size() && std::memcmp(filename.data(), filename_base.data(), filename_base.size()) == 0) |