diff options
author | Douglas Christman <DouglasChristman@gmail.com> | 2016-11-24 12:21:37 -0500 |
---|---|---|
committer | Douglas Christman <DouglasChristman@gmail.com> | 2016-11-24 18:22:08 -0500 |
commit | 04773cb50aca6484921c40bef3cbc0171c1e4786 (patch) | |
tree | e3e92859ac24ebd7ddabbbc115549fcc4d1093bf | |
parent | 408a51e15614ca0c6cd80558adb20efe448d16d8 (diff) |
calendarspec: reject strings that only contain a timezone
This makes " UTC" an illegal date specification.
-rw-r--r-- | src/basic/calendarspec.c | 8 | ||||
-rw-r--r-- | src/test/test-calendarspec.c | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c index db11e55390..316db5c556 100644 --- a/src/basic/calendarspec.c +++ b/src/basic/calendarspec.c @@ -779,9 +779,6 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) { assert(p); assert(spec); - if (isempty(p)) - return -EINVAL; - c = new0(CalendarSpec, 1); if (!c) return -ENOMEM; @@ -820,6 +817,11 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) { } } + if (isempty(p)) { + r = -EINVAL; + goto fail; + } + if (strcaseeq(p, "minutely")) { r = const_chain(0, &c->microsecond); if (r < 0) diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c index 7357c522e0..c539d16867 100644 --- a/src/test/test-calendarspec.c +++ b/src/test/test-calendarspec.c @@ -202,6 +202,7 @@ int main(int argc, char* argv[]) { test_next("Mon 2017-05~07/1 UTC", "", 12345, 1496016000000000); assert_se(calendar_spec_from_string("test", &c) < 0); + assert_se(calendar_spec_from_string(" utc", &c) < 0); assert_se(calendar_spec_from_string(" ", &c) < 0); assert_se(calendar_spec_from_string("", &c) < 0); assert_se(calendar_spec_from_string("7", &c) < 0); |