public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Fix 32-bit overflow in mktime() when time_t is 64-bits long Date: Tue, 29 May 2018 13:27:00 -0000 [thread overview] Message-ID: <20180529132715.105912.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3305f3557064a3cc981e3566959d7833bb81e192 commit 3305f3557064a3cc981e3566959d7833bb81e192 Author: Freddie Chopin <freddie.chopin@gmail.com> Date: Tue May 15 20:58:08 2018 +0200 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> Diff: --- newlib/libc/time/mktime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/newlib/libc/time/mktime.c b/newlib/libc/time/mktime.c index 9bcef32..0203259 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;
reply other threads:[~2018-05-29 13:27 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180529132715.105912.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=newlib-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).