mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Merge bitcoin/bitcoin#27317: log: Check that the timestamp string is non-empty to avoid undefined behavior
73f4eb511c
Check that the Timestamp String is valid (John Moffett) Pull request description: Follow-up to https://github.com/bitcoin/bitcoin/pull/27233 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, here `strStamped.pop_back()` would be undefined behavior. ACKs for top commit: MarcoFalke: lgtm ACK73f4eb511c
stickies-v: ACK73f4eb511c
Tree-SHA512: 089ed639c193deb98870a8385039b31b4baed821ea907937bfc6f65a5b0981bbf8284b2afec81b2d0a922e2340716b48cf55349640eb6b8c311ef7af25abc361
This commit is contained in:
commit
27ad26de2f
@ -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