mirror of
https://github.com/systemd/systemd.git
synced 2026-08-13 17:08:14 +00:00
calendarspec: use ADD_SAFE for repeat offset calculation
Use overflow-safe ADD_SAFE() instead of raw addition when
computing the next matching calendar component with repeat.
On overflow, skip the component instead of using a bogus value.
CID#1548052
Follow-up for a2eb5ea79c
This commit is contained in:
@@ -1149,9 +1149,8 @@ static int find_matching_component(
|
||||
} else if (c->repeat > 0) {
|
||||
int k;
|
||||
|
||||
k = start + ROUND_UP(*val - start, c->repeat);
|
||||
|
||||
if ((!d_set || k < d) && (stop < 0 || k <= stop)) {
|
||||
if (ADD_SAFE(&k, start, ROUND_UP(*val - start, c->repeat)) &&
|
||||
(!d_set || k < d) && (stop < 0 || k <= stop)) {
|
||||
d = k;
|
||||
d_set = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user