chiark / gitweb /
Prep v233: Unmask now needed functions in src/basic
[elogind.git] / src / basic / time-util.c
index 265f5995a2e1b21e145c71a424f8ddb2a284a9c0..a2b57f872716a37ecdb6de7adbbaf5f998c431cb 100644 (file)
@@ -218,7 +218,7 @@ struct timespec *timespec_store(struct timespec *ts, usec_t u)  {
         assert(ts);
 
         if (u == USEC_INFINITY ||
-            u / USEC_INFINITY >= TIME_T_MAX) {
+            u / USEC_PER_SEC >= TIME_T_MAX) {
                 ts->tv_sec = (time_t) -1;
                 ts->tv_nsec = (long) -1;
                 return ts;
@@ -857,6 +857,8 @@ from_tm:
                 return -EINVAL;
 
 finish:
+        if (ret + plus < ret) /* overflow? */
+                return -EINVAL;
         ret += plus;
         if (ret > USEC_TIMESTAMP_FORMATTABLE_MAX)
                 return -EINVAL;