mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-26 04:54:07 +01:00
For architectures where time_t is wide enough, in particular, 64bit
platforms, avoid overflow after year 2038 in clock_ct_to_ts(). PR: 195868 Reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
0f49f14626
commit
fe21241ee0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=275727
@ -133,7 +133,6 @@ print_ct(struct clocktime *ct)
|
||||
int
|
||||
clock_ct_to_ts(struct clocktime *ct, struct timespec *ts)
|
||||
{
|
||||
time_t secs;
|
||||
int i, year, days;
|
||||
|
||||
year = ct->year;
|
||||
@ -167,11 +166,10 @@ clock_ct_to_ts(struct clocktime *ct, struct timespec *ts)
|
||||
days += days_in_month(year, i);
|
||||
days += (ct->day - 1);
|
||||
|
||||
/* Add hours, minutes, seconds. */
|
||||
secs = ((days * 24 + ct->hour) * 60 + ct->min) * 60 + ct->sec;
|
||||
|
||||
ts->tv_sec = secs;
|
||||
ts->tv_sec = (((time_t)days * 24 + ct->hour) * 60 + ct->min) * 60 +
|
||||
ct->sec;
|
||||
ts->tv_nsec = ct->nsec;
|
||||
|
||||
if (ct_debug)
|
||||
printf(" = %ld.%09ld\n", (long)ts->tv_sec, (long)ts->tv_nsec);
|
||||
return (0);
|
||||
|
Loading…
Reference in New Issue
Block a user