This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v4] Ensure mktime sets errno on error (bug 23789)


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.


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?
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.

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.

Attachment: 0001-mktime-fix-EOVERFLOW-bug.txt
Description: Text document

Attachment: 0002-mktime-new-test-for-mktime-failure.txt
Description: Text document

Attachment: 0003-mktime-simplify-offset-guess.txt
Description: Text document

Attachment: 0004-mktime-make-more-room-for-overflow.txt
Description: Text document

Attachment: 0005-mktime-fix-bug-with-Y2038-DST-transition.txt
Description: Text document

Attachment: 0006-mktime-fix-non-EOVERFLOW-errno-handling.txt
Description: Text document

Attachment: 0007-mktime-DEBUG_MKTIME-cleanup.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]