This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix p_secstodate overflow handling (bug 22463)
On Tue, 21 Nov 2017, Paul Eggert wrote:
> Attached is an (untested) patch with this simplification in mind. It uses your
> idea of a 'clock < 0' test along with a static assertion (though the assertion
> is merely that time_t is at least 32 bits wide, since that's all we need now)
> to avoid the need for complicated integer-overflow checking. It uses my idea
> to use strftime instead of sprintf to simplify and shorten the code and avoid
> having confusing gotos and pragmas merely to pacify GCC's false alarms. And it
> passes just an unsigned int to sprintf so that GCC doesn't spout off
> unnecessarily about format overflow.
The strftime use is incorrect - the %M%D needs to be %m%d. This
illustrates the need for including testcases, as in my second patch.
--
Joseph S. Myers
joseph@codesourcery.com