On 15 Jan 2002 at 10:05, Ian Abbott wrote:

> I had ago at building wget 1.8.1 myself on Windows 2000 with VC 6.0
> and also got the crash when using the -d option, so I upgraded to
> VC 6.0 SP2 and it did the same thing.
> 
> I've narrowed it down to the following line in cookies.c
> 
>            asctime (localtime ((time_t *)&cookie->expiry_time)),

Replying to myself and delving a little deeper, cookie->expiry_time
was set to (unsigned long)(-1). This causes Microsoft's
implementation of localtime to return a NULL pointer (from
Microsoft's documentation: "If the value in timer represents a date
before midnight, January 1, 1970, localtime returns NULL."). The
asctime function craps out when passed a NULL pointer.

The cookie came from Google and had the following
pseudo-RFC850 expiry time string: "Sun, 17-Jan-2038 19:15:07 GMT". The http_atotm 
function in http.c failed to handle this string and
returned -1.

The strptime_internal function only handles years up to 2036 for
case 'Y' (unless sizeof(time_t) > 4).

The quick fix for strptime_internal is to accept years up to 2038.
Even though not all dates in 2038 are representable when the
http_atotm function converts the struct tm from strptime to a
time_t value, the mktime function would return an error for such
dates. In fact, is there any reason why strptime_internal can't
accept years up to 9999 regardless? 

Reply via email to