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>
This commit is contained in:
Freddie Chopin 2018-05-15 20:58:08 +02:00 committed by Corinna Vinschen
parent e928275566
commit 3305f35570
1 changed files with 1 additions and 1 deletions

View File

@ -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;