diff options
author | Freddie Chopin <freddie.chopin@gmail.com> | 2018-05-15 21:58:08 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2018-05-29 16:27:03 +0300 |
commit | 3305f3557064a3cc981e3566959d7833bb81e192 (patch) | |
tree | ab5c3c31040ba3428f2dfcc4ae38f0a45423231d /newlib/libc/time | |
parent | e928275566ab8168c078eadee2043a002bd9352d (diff) |
Fix 32-bit overflow in mktime() when time_t is 64-bits long
When converting number of days since epoch (32-bits) to seconds,
calculations using 32-bit `long` overflow for years above 2038. Solve
this by casting number of days to `time_t` just before final
multiplication.
Signed-off-by: Freddie Chopin <freddie.chopin@gmail.com>
Diffstat (limited to 'newlib/libc/time')
-rw-r--r-- | newlib/libc/time/mktime.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/newlib/libc/time/mktime.c b/newlib/libc/time/mktime.c index 9bcef3268..02032599a 100644 --- a/newlib/libc/time/mktime.c +++ b/newlib/libc/time/mktime.c @@ -188,7 +188,7 @@ mktime (struct tm *tim_p) } /* compute total seconds */ - tim += (days * _SEC_IN_DAY); + tim += (time_t)days * _SEC_IN_DAY; TZ_LOCK; |