|
From: | Paul Eggert |
Subject: | Re: [PATCH v4] Ensure mktime sets errno on error (bug 23789) |
Date: | Fri, 9 Nov 2018 18:00:25 -0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 |
On 11/7/18 6:48 AM, Albert ARIBAUD wrote:
1. If the for-loop reaches remaining_probes==0, then it really should set errno = EOVERFLOW before returning -1, because remaining_probes is only decremented in the else clause inside the for-loop, and that only happens (or should only happen) when there were no failures so far, so if we fail then, we have to set errno.
Thanks for the diagnosis. Revised patches attached, which set errno in that case as you suggested.
2. It is not normal that t, gt, t1 and t2 remain the same for all six iterations of the for-loop. That should be investigated and fixed.
Long ago I came up with weird scenarios involving odd combinations of leap seconds and DST transitions all near the maximum convertible time_t values that could involve that many iterations. None of these scenarios will ever happen, really; the number is that large just to be safe. It could be that I overestimated the number, but that's no big deal.
Because it communicates back to the caller the nearest long_int value that is in range. This value is not obvious because it can depend on timezone and leap second information.I don't know why ranged_convert alters an argument which should be a pure imput. In fact, I don't know why it does not just copy this argument into a local time_t. Any known reason?
After looking at the mktime implementation again I see some other things that need fixing. These are mostly for Gnulib (when we can't assume that localtime_r fails only due to EOVERFLOW), but there are some code cleanups and fixes for very unlikely bugs. Proposed glibc patches attached.
0001-mktime-fix-EOVERFLOW-bug.txt
Description: Text document
0002-mktime-new-test-for-mktime-failure.txt
Description: Text document
0003-mktime-simplify-offset-guess.txt
Description: Text document
0004-mktime-make-more-room-for-overflow.txt
Description: Text document
0005-mktime-fix-bug-with-Y2038-DST-transition.txt
Description: Text document
0006-mktime-fix-non-EOVERFLOW-errno-handling.txt
Description: Text document
0007-mktime-DEBUG_MKTIME-cleanup.txt
Description: Text document
[Prev in Thread] | Current Thread | [Next in Thread] |