From d25b0503795f1fbf557632ce870298f52f2a78c1 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Mon, 5 Feb 2018 21:57:39 +0100 Subject: time-cond: fix reading the file modification time on Windows On Windows, stat() may adjust the unix file time by a daylight saving time offset. Avoid this by calling GetFileTime() instead. Fixes #2164 Closes #2204 --- src/tool_getparam.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/tool_getparam.c') diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 015d63551..46e7dd3cd 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -31,6 +31,7 @@ #include "tool_cfgable.h" #include "tool_cb_prg.h" #include "tool_convert.h" +#include "tool_filetime.h" #include "tool_formparse.h" #include "tool_getparam.h" #include "tool_helpers.h" @@ -2087,11 +2088,15 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ break; } now = time(NULL); - config->condtime = curl_getdate(nextarg, &now); - if(-1 == (int)config->condtime) { + config->condtime = (curl_off_t)curl_getdate(nextarg, &now); + if(-1 == config->condtime) { /* now let's see if it is a file name to get the time from instead! */ - struct_stat statbuf; - if(-1 == stat(nextarg, &statbuf)) { + curl_off_t filetime = getfiletime(nextarg, config->global->errors); + if(filetime >= 0) { + /* pull the time out from the file */ + config->condtime = filetime; + } + else { /* failed, remove time condition */ config->timecond = CURL_TIMECOND_NONE; warnf(global, @@ -2099,10 +2104,6 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ "a file name). Disabling time condition. " "See curl_getdate(3) for valid date syntax.\n"); } - else { - /* pull the time out from the file */ - config->condtime = statbuf.st_mtime; - } } break; default: /* unknown flag */ -- cgit v1.2.3