mirror of
https://github.com/mirror/wget.git
synced 2025-01-08 11:20:24 +08:00
[svn] Zero out all of struct tm before passing it to strptime.
This commit is contained in:
parent
bb60858a3f
commit
a231f88b54
@ -1,3 +1,8 @@
|
|||||||
|
2005-05-05 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* http.c (http_atotm): Zero out the whole struct tm being passed
|
||||||
|
to strptime.
|
||||||
|
|
||||||
2005-05-05 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-05-05 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* main.c (main): Propagate option name to setoptval.
|
* main.c (main): Propagate option name to setoptval.
|
||||||
|
28
src/http.c
28
src/http.c
@ -2633,30 +2633,30 @@ http_atotm (const char *time_string)
|
|||||||
(google.com uses this for their cookies.) */
|
(google.com uses this for their cookies.) */
|
||||||
"%a %b %d %T %Y" /* asctime: Thu Jan 29 22:12:57 1998 */
|
"%a %b %d %T %Y" /* asctime: Thu Jan 29 22:12:57 1998 */
|
||||||
};
|
};
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < countof (time_formats); i++)
|
||||||
|
{
|
||||||
struct tm t;
|
struct tm t;
|
||||||
|
|
||||||
/* According to Roger Beeman, we need to initialize tm_isdst, since
|
/* Some versions of strptime use the existing contents of struct
|
||||||
strptime won't do it. */
|
tm to recalculate the date according to format. Zero it out
|
||||||
t.tm_isdst = 0;
|
to prevent garbage from the stack influencing strptime. */
|
||||||
|
xzero (t);
|
||||||
|
|
||||||
/* Note that under foreign locales Solaris strptime() fails to
|
/* Note that under non-English locales Solaris strptime() fails
|
||||||
recognize English dates, which renders this function useless. We
|
to recognize English dates, which renders it useless for this
|
||||||
solve this by being careful not to affect LC_TIME when
|
purpose. We solve this by not setting LC_TIME when
|
||||||
initializing locale.
|
initializing locale. Another solution would be to
|
||||||
|
temporarily set locale to C, invoke strptime(), and restore
|
||||||
Another solution would be to temporarily set locale to C, invoke
|
it back, but that is somewhat slow and dirty.
|
||||||
strptime(), and restore it back. This is slow and dirty,
|
|
||||||
however, and locale support other than LC_MESSAGES can mess other
|
|
||||||
things, so I rather chose to stick with just setting LC_MESSAGES.
|
|
||||||
|
|
||||||
GNU strptime does not have this problem because it recognizes
|
GNU strptime does not have this problem because it recognizes
|
||||||
both international and local dates. */
|
both international and local dates. */
|
||||||
|
|
||||||
for (i = 0; i < countof (time_formats); i++)
|
|
||||||
if (check_end (strptime (time_string, time_formats[i], &t)))
|
if (check_end (strptime (time_string, time_formats[i], &t)))
|
||||||
return mktime_from_utc (&t);
|
return mktime_from_utc (&t);
|
||||||
|
}
|
||||||
|
|
||||||
/* All formats have failed. */
|
/* All formats have failed. */
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user