Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paranoia for overflow of sprintf buffer in the year 10000 #1106

Merged
merged 1 commit into from
Apr 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Release/src/utilities/asyncrt_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ utility::string_t datetime::to_string(date_format format) const
const int64_t input = static_cast<int64_t>(m_interval / _secondTicks); // convert to seconds
const int frac_sec = static_cast<int>(m_interval % _secondTicks);
const time_t time = static_cast<time_t>(input - ntToUnixOffsetSeconds);
if (static_cast<uint64_t>(time) > 253370764800ull) {
throw std::out_of_range("The requested year exceeds the year 9999.");
}

struct tm t;
#ifdef _MSC_VER
if (gmtime_s(&t, &time) != 0)
Expand Down