* main: call tzset() to ensure TZ is setup for other <time.h> functions.
* remotemodtime(): use strptime() to parse the reply. * fetch_url(): ensure struct tm is zeroed before calling strptime().
This commit is contained in:
parent
719ec3a2b9
commit
3ba7505832
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fetch.c,v 1.177 2007/05/15 23:54:18 lukem Exp $ */
|
||||
/* $NetBSD: fetch.c,v 1.178 2007/05/22 05:16:48 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2007 The NetBSD Foundation, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fetch.c,v 1.177 2007/05/15 23:54:18 lukem Exp $");
|
||||
__RCSID("$NetBSD: fetch.c,v 1.178 2007/05/22 05:16:48 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -929,6 +929,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
|
||||
struct tm parsed;
|
||||
char *t;
|
||||
|
||||
memset(&parsed, 0, sizeof(parsed));
|
||||
/* RFC1123 */
|
||||
if ((t = strptime(cp,
|
||||
"%a, %d %b %Y %H:%M:%S GMT",
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.104 2007/04/17 05:52:03 lukem Exp $ */
|
||||
/* $NetBSD: main.c,v 1.105 2007/05/22 05:16:48 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
|
||||
@ -104,7 +104,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.104 2007/04/17 05:52:03 lukem Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.105 2007/05/22 05:16:48 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -123,6 +123,7 @@ __RCSID("$NetBSD: main.c,v 1.104 2007/04/17 05:52:03 lukem Exp $");
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
|
||||
@ -147,6 +148,7 @@ main(int volatile argc, char **volatile argv)
|
||||
size_t len;
|
||||
socklen_t slen;
|
||||
|
||||
tzset();
|
||||
setlocale(LC_ALL, "");
|
||||
setprogname(argv[0]);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: util.c,v 1.139 2007/05/15 23:54:19 lukem Exp $ */
|
||||
/* $NetBSD: util.c,v 1.140 2007/05/22 05:16:48 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2007 The NetBSD Foundation, Inc.
|
||||
@ -71,7 +71,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: util.c,v 1.139 2007/05/15 23:54:19 lukem Exp $");
|
||||
__RCSID("$NetBSD: util.c,v 1.140 2007/05/22 05:16:48 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -717,7 +717,6 @@ remotemodtime(const char *file, int noisy)
|
||||
if (r == COMPLETE) {
|
||||
struct tm timebuf;
|
||||
char *timestr, *frac;
|
||||
int yy, mo, day, hour, min, sec;
|
||||
|
||||
/*
|
||||
* time-val = 14DIGIT [ "." 1*DIGIT ]
|
||||
@ -749,20 +748,13 @@ remotemodtime(const char *file, int noisy)
|
||||
timestr[1] = '0';
|
||||
fprintf(ttyout, "Converted to `%s'\n", timestr);
|
||||
}
|
||||
memset(&timebuf, 0, sizeof(timebuf));
|
||||
if (strlen(timestr) != 14 ||
|
||||
sscanf(timestr, "%04d%02d%02d%02d%02d%02d",
|
||||
&yy, &mo, &day, &hour, &min, &sec) != 6) {
|
||||
(strptime(timestr, "%Y%m%d%H%M%S", &timebuf) == NULL)) {
|
||||
bad_parse_time:
|
||||
fprintf(ttyout, "Can't parse time `%s'.\n", timestr);
|
||||
goto cleanup_parse_time;
|
||||
}
|
||||
memset(&timebuf, 0, sizeof(timebuf));
|
||||
timebuf.tm_sec = sec;
|
||||
timebuf.tm_min = min;
|
||||
timebuf.tm_hour = hour;
|
||||
timebuf.tm_mday = day;
|
||||
timebuf.tm_mon = mo - 1;
|
||||
timebuf.tm_year = yy - TM_YEAR_BASE;
|
||||
timebuf.tm_isdst = -1;
|
||||
rtime = timegm(&timebuf);
|
||||
if (rtime == -1) {
|
||||
@ -771,7 +763,8 @@ remotemodtime(const char *file, int noisy)
|
||||
else
|
||||
goto cleanup_parse_time;
|
||||
} else
|
||||
DPRINTF("parsed date as: %s", ctime(&rtime));
|
||||
DPRINTF("parsed date `%s' as %ld, %s",
|
||||
timestr, rtime, ctime(&rtime));
|
||||
} else {
|
||||
if (r == ERROR && code == 500 && features[FEAT_MDTM] == -1)
|
||||
features[FEAT_MDTM] = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: version.h,v 1.65 2007/05/15 23:54:19 lukem Exp $ */
|
||||
/* $NetBSD: version.h,v 1.66 2007/05/22 05:16:48 lukem Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1999-2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@ -40,5 +40,5 @@
|
||||
#endif
|
||||
|
||||
#ifndef FTP_VERSION
|
||||
#define FTP_VERSION "20070515"
|
||||
#define FTP_VERSION "20070522"
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user