Limit the allowed epoch timestamps (#3651)

The code for parsing epoch timestamps when displaying tasks only
supports values between year 1980 and 9999. Previous to this change, it
was possible to set e.g., the due timestamp to a value outside of these
limits, which would make it impossible to later on show the task.

With this change, we only allow setting values within the same limits
used by the code for displaying tasks.
This commit is contained in:
Fredrik Lanker 2024-10-24 01:18:21 +02:00 committed by GitHub
parent 2db373d631
commit af8c5d58c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -190,7 +190,11 @@ void ColumnTypeDate::modify(Task& task, const std::string& value) {
if (value != "" && evaluatedValue.get_date() == 0)
throw format("'{1}' is not a valid date in the '{2}' format.", value, Variant::dateFormat);
task.set(_name, evaluatedValue.get_date());
time_t epoch = evaluatedValue.get_date();
if (epoch < EPOCH_MIN_VALUE || epoch >= EPOCH_MAX_VALUE) {
throw format("'{1}' is not a valid date.", value);
}
task.set(_name, epoch);
}
////////////////////////////////////////////////////////////////////////////////