mirror of
https://github.com/systemd/systemd.git
synced 2025-03-22 06:50:18 +03:00
time-util: when converting to time_t do something useful in 2038
On systems where time_t is 32bit we should invalidate the timeval/timespec instead of proceeding with a potentially overflown value.
This commit is contained in:
parent
1bb4b028a3
commit
f977849c24
@ -211,7 +211,8 @@ nsec_t timespec_load_nsec(const struct timespec *ts) {
|
|||||||
struct timespec *timespec_store(struct timespec *ts, usec_t u) {
|
struct timespec *timespec_store(struct timespec *ts, usec_t u) {
|
||||||
assert(ts);
|
assert(ts);
|
||||||
|
|
||||||
if (u == USEC_INFINITY) {
|
if (u == USEC_INFINITY ||
|
||||||
|
u / USEC_INFINITY >= TIME_T_MAX) {
|
||||||
ts->tv_sec = (time_t) -1;
|
ts->tv_sec = (time_t) -1;
|
||||||
ts->tv_nsec = (long) -1;
|
ts->tv_nsec = (long) -1;
|
||||||
return ts;
|
return ts;
|
||||||
@ -240,7 +241,8 @@ usec_t timeval_load(const struct timeval *tv) {
|
|||||||
struct timeval *timeval_store(struct timeval *tv, usec_t u) {
|
struct timeval *timeval_store(struct timeval *tv, usec_t u) {
|
||||||
assert(tv);
|
assert(tv);
|
||||||
|
|
||||||
if (u == USEC_INFINITY) {
|
if (u == USEC_INFINITY||
|
||||||
|
u / USEC_PER_SEC > TIME_T_MAX) {
|
||||||
tv->tv_sec = (time_t) -1;
|
tv->tv_sec = (time_t) -1;
|
||||||
tv->tv_usec = (suseconds_t) -1;
|
tv->tv_usec = (suseconds_t) -1;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user