chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
time-util: when converting to time_t do something useful in 2038
[elogind.git]
/
src
/
basic
/
time-util.c
diff --git
a/src/basic/time-util.c
b/src/basic/time-util.c
index b8f56544de8ae58117ef250925af1cc4354a1894..1fcbbaa478aed679e808b81c4e256aa735103ebf 100644
(file)
--- a/
src/basic/time-util.c
+++ b/
src/basic/time-util.c
@@
-217,7
+217,8
@@
nsec_t timespec_load_nsec(const struct timespec *ts) {
struct timespec *timespec_store(struct timespec *ts, usec_t u) {
assert(ts);
struct timespec *timespec_store(struct timespec *ts, usec_t u) {
assert(ts);
- if (u == USEC_INFINITY) {
+ if (u == USEC_INFINITY ||
+ u / USEC_INFINITY >= TIME_T_MAX) {
ts->tv_sec = (time_t) -1;
ts->tv_nsec = (long) -1;
return ts;
ts->tv_sec = (time_t) -1;
ts->tv_nsec = (long) -1;
return ts;
@@
-246,7
+247,8
@@
usec_t timeval_load(const struct timeval *tv) {
struct timeval *timeval_store(struct timeval *tv, usec_t u) {
assert(tv);
struct timeval *timeval_store(struct timeval *tv, usec_t u) {
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_usec = (suseconds_t) -1;
} else {
tv->tv_sec = (time_t) -1;
tv->tv_usec = (suseconds_t) -1;
} else {