strptime() could hangs for hours

Corinna Vinschen
Fri Apr 1 15:02:00 GMT 2011

On Mar 31 11:58, Howland Craig D (Craig) wrote:
> 2011-03-30  Craig Howland <...>
> 	* libc/time/strptime.c:  Initialize given struct tm before use;
> 	move application of %U, %W, and %V formats to the end so that have
> 	a valid year to use first; re-write first_day() helper function
> 	to be faster for large values and to work for year < 1970; limit
> 	year to 1753 or later.

Thanks for the patch.  I don't think it's right to limit the date
to >= 1753, though.  Think about it:

  strptime ("Apr 01, 1489", "%b %d, %Y", tm_ptr);

There's no good reason to treat this as wrong.  If anything, you could
skip the %[UVW] handling for dates < 1753.


Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

More information about the Newlib mailing list