Fix p_secstodate overflow handling (bug 22463)

Joseph Myers joseph@codesourcery.com
Tue Nov 21 22:27:00 GMT 2017


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



More information about the Libc-alpha mailing list