diff options
Diffstat (limited to 'src/shared/calendarspec.c')
-rw-r--r-- | src/shared/calendarspec.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c index 084965e64e..b162224d9d 100644 --- a/src/shared/calendarspec.c +++ b/src/shared/calendarspec.c @@ -91,6 +91,16 @@ static void normalize_chain(CalendarComponent **c) { if (i->stop > i->start && i->repeat > 0) i->stop -= (i->stop - i->start) % i->repeat; + /* If a repeat value is specified, but it cannot even be triggered once, let's suppress + * it. + * + * Similar, if the stop value is the same as the start value, then let's just make this a + * non-repeating chain element */ + if ((i->stop > i->start && i->repeat > 0 && i->start + i->repeat > i->stop) || + i->start == i->stop) { + i->repeat = 0; + i->stop = -1; + } } if (n <= 1) @@ -645,6 +655,12 @@ static int prepend_component(const char **p, bool usec, unsigned nesting, Calend if (repeat == 0) return -ERANGE; + } else { + /* If no repeat value is specified for the µs component, then let's explicitly refuse ranges + * below 1s because our default repeat granularity is beyond that. */ + + if (usec && stop >= 0 && start + repeat > stop) + return -EINVAL; } if (!IN_SET(*e, 0, ' ', ',', '-', '~', ':')) |