]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/time-util.c
time: time_t is signed, and mktime() is happy to return negative time
authorLennart Poettering <lennart@poettering.net>
Thu, 2 Feb 2017 17:25:33 +0000 (18:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 2 Feb 2017 19:12:31 +0000 (20:12 +0100)
commitc477ff141b875a2a98c90514b6bf23f0436d1f73
treefb0530801b5eed094dcd2ca0a353a5b36dbac125
parentced58da749367fa70b00d00959272054aa7ab48a
time: time_t is signed, and mktime() is happy to return negative time

Passing a year such as 1960 to mktime() will result in a negative return
value. This is quite confusing, as the man page claims that on failure
the call will return -1...

Given that our own usec_t type is unsigned, and we can't express times
before 1970 hence, let's consider all negative times returned by
mktime() as invalid, regardless if just -1, or anything else negative.
src/basic/calendarspec.c
src/basic/time-util.c