Skip to content
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
14 changes: 7 additions & 7 deletions src/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,20 +925,20 @@ int TimeValue::read(const std::string& buf) {
}

auto hi = std::stoi(buf.substr(0, 2));
if (hi > 23)
if (hi < 0 || hi > 23)
return printWarning();
time_.hour = hi;
if (buf.size() > 3) {
auto mi = std::stoi(buf.substr(mpos, 2));
if (mi > 59)
if (mi < 0 || mi > 59)
return printWarning();
time_.minute = std::stoi(buf.substr(mpos, 2));
} else {
time_.minute = 0;
}
if (buf.size() > 5) {
auto si = std::stoi(buf.substr(spos, 2));
if (si > 60)
if (si < 0 || si > 60)
return printWarning();
time_.second = std::stoi(buf.substr(spos, 2));
} else {
Expand All @@ -955,23 +955,23 @@ int TimeValue::read(const std::string& buf) {
if (posColon == std::string::npos) {
// Extended format
auto tzhi = std::stoi(format.substr(0, 3));
if (tzhi > 23)
if (tzhi < -23 || tzhi > 23)
return printWarning();
time_.tzHour = tzhi;
if (format.size() > 3) {
int minute = std::stoi(format.substr(3));
if (minute > 59)
if (minute < 0 || minute > 59)
return printWarning();
time_.tzMinute = time_.tzHour < 0 ? -minute : minute;
}
} else {
// Basic format
auto tzhi = std::stoi(format.substr(0, posColon));
if (tzhi > 23)
if (tzhi < -23 || tzhi > 23)
Copy link
Collaborator

@kmilos kmilos Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could limit this (and one above) even more from -12 to 14 strictly speaking, but I guess this is just to keep the fuzzer from going to crazy...

return printWarning();
time_.tzHour = tzhi;
int minute = std::stoi(format.substr(posColon + 1));
if (minute > 59)
if (minute < 0 || minute > 59)
return printWarning();
time_.tzMinute = time_.tzHour < 0 ? -minute : minute;
}
Expand Down