summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorDouglas Christman <DouglasChristman@gmail.com>2016-11-24 14:04:13 -0500
committerDouglas Christman <DouglasChristman@gmail.com>2016-11-24 18:22:08 -0500
commit6bae2fd4cdddd6c34f3d5e79906d8f6a75125922 (patch)
tree33840260dc3d6e8fdffae6bf9814b64126f26a0f /src/basic
parent04773cb50aca6484921c40bef3cbc0171c1e4786 (diff)
downloadsystemd-6bae2fd4cdddd6c34f3d5e79906d8f6a75125922.tar.gz
systemd-6bae2fd4cdddd6c34f3d5e79906d8f6a75125922.tar.bz2
systemd-6bae2fd4cdddd6c34f3d5e79906d8f6a75125922.zip
calendarspec: reject open weekday ranges
Forbid open ranges like "Tue.."; trailing commas are still OK.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/calendarspec.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c
index 316db5c556..eef4ed5240 100644
--- a/src/basic/calendarspec.c
+++ b/src/basic/calendarspec.c
@@ -372,9 +372,6 @@ static int parse_weekdays(const char **p, CalendarSpec *c) {
for (;;) {
unsigned i;
- if (!first && **p == ' ')
- return 0;
-
for (i = 0; i < ELEMENTSOF(day_nr); i++) {
size_t skip;
@@ -430,7 +427,7 @@ static int parse_weekdays(const char **p, CalendarSpec *c) {
return -EINVAL;
l = day_nr[i].nr;
- *p += 1;
+ *p += 2;
/* Support ranges with "-" for backwards compatibility */
} else if (**p == '-') {
@@ -438,10 +435,19 @@ static int parse_weekdays(const char **p, CalendarSpec *c) {
return -EINVAL;
l = day_nr[i].nr;
- } else
+ *p += 1;
+
+ } else if (**p == ',') {
l = -1;
+ *p += 1;
+ }
+
+ /* Allow a trailing comma but not an open range */
+ if (**p == 0 || **p == ' ') {
+ *p += strspn(*p, " ");
+ return l < 0 ? 0 : -EINVAL;
+ }
- *p += 1;
first = false;
}
}