diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index 3531aa481b7..f37f3329488 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -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.