mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-17 13:53:39 +00:00
Fix a nasty bug exposed by mktime() when time_t is significantly bigger
than 32 bits. It was trying to figure out things like the day of week of when time_t is roughly 2^62 etc. Make a better guess for the starting point for the binary search that works on both 32 and 64 bit types. I have been using this for a while now.
This commit is contained in:
parent
162e98939f
commit
b331ec93c0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102885
|
@ -1475,6 +1475,12 @@ int * const okayp;
|
|||
** (this works whether time_t is signed or unsigned).
|
||||
*/
|
||||
bits = TYPE_BIT(time_t) - 1;
|
||||
/*
|
||||
* Limit to 32 bits or the things go crazy
|
||||
* when it tries to figure out times near 2^62 etc.
|
||||
*/
|
||||
if (bits > 31)
|
||||
bits = 31;
|
||||
/*
|
||||
** If time_t is signed, then 0 is just above the median,
|
||||
** assuming two's complement arithmetic.
|
||||
|
|
Loading…
Reference in a new issue