Skip to content

Commit c9707ef

Browse files
authored
Paranoia for overflow of sprintf buffer in the year 10000 (#1106)
1 parent 5583fbb commit c9707ef

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Release/src/utilities/asyncrt_utils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,10 @@ utility::string_t datetime::to_string(date_format format) const
649649
const int64_t input = static_cast<int64_t>(m_interval / _secondTicks); // convert to seconds
650650
const int frac_sec = static_cast<int>(m_interval % _secondTicks);
651651
const time_t time = static_cast<time_t>(input - ntToUnixOffsetSeconds);
652+
if (static_cast<uint64_t>(time) > 253370764800ull) {
653+
throw std::out_of_range("The requested year exceeds the year 9999.");
654+
}
655+
652656
struct tm t;
653657
#ifdef _MSC_VER
654658
if (gmtime_s(&t, &time) != 0)

0 commit comments

Comments
 (0)