mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Check that the Timestamp String is valid
The current `FormatISO8601DateTime` function will return an empty string if it encounters an error when converting the `int64_t` seconds since epoch to a formatted date time. In the unlikely case that happens, `strStamped.pop_back()` would be undefined behavior.
This commit is contained in:
parent
381593c906
commit
73f4eb511c
@ -352,7 +352,7 @@ std::string BCLog::Logger::LogTimestampStr(const std::string& str)
|
||||
const auto now{SystemClock::now()};
|
||||
const auto now_seconds{std::chrono::time_point_cast<std::chrono::seconds>(now)};
|
||||
strStamped = FormatISO8601DateTime(TicksSinceEpoch<std::chrono::seconds>(now_seconds));
|
||||
if (m_log_time_micros) {
|
||||
if (m_log_time_micros && !strStamped.empty()) {
|
||||
strStamped.pop_back();
|
||||
strStamped += strprintf(".%06dZ", Ticks<std::chrono::microseconds>(now - now_seconds));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user