diff options
author | Yunusemre Şentürk <yunusemre@collabora.com> | 2022-01-21 15:44:39 +0300 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2022-01-21 16:52:20 +0100 |
commit | a41995accdbf86f27469ce8ab5a6c1f63f765491 (patch) | |
tree | c749c9a965a2d872862d66dddd425794f662f015 /wsd/AdminModel.cpp | |
parent | use gmtime_r instead of std::gmtime for thread safe purposes (diff) | |
download | online-a41995accdbf86f27469ce8ab5a6c1f63f765491.tar.gz online-a41995accdbf86f27469ce8ab5a6c1f63f765491.zip |
Admin: make time output thread secure
Change-Id: I3927ef9989de2217dee6c4b3034c9ffbd8fb184d
Signed-off-by: Yunusemre Şentürk <yunusemre@collabora.com>
Diffstat (limited to 'wsd/AdminModel.cpp')
-rw-r--r-- | wsd/AdminModel.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp index a9627a303b..c6ef3d42d8 100644 --- a/wsd/AdminModel.cpp +++ b/wsd/AdminModel.cpp @@ -555,10 +555,13 @@ void AdminModel::addDocument(const std::string& docKey, pid_t pid, { std::ostringstream osst; Poco::AutoPtr<Poco::Channel> channel = Log::logger().getChannel(); - const auto now = std::chrono::system_clock::now(); - const auto current = std::chrono::system_clock::to_time_t(now); - osst << std::put_time(std::localtime(¤t), "%F %T") - << " docstats : adding a document : " << filename + char output[64]; + std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); + std::time_t current = std::chrono::system_clock::to_time_t(now); + std::tm tm; + gmtime_r(¤t, &tm); + strftime(output, sizeof(output), "%F %T", &tm); + osst << output << " docstats : adding a document : " << filename << ", created by : " << COOLWSD::anonymizeUsername(userName) << ", using WopiHost : " << COOLWSD::anonymizeUrl(wopiHost) << ", allocating memory of : " << memoryAllocated; |