diff options
author | Michael Kaufmann <mail@michael-kaufmann.ch> | 2018-02-05 21:57:39 +0100 |
---|---|---|
committer | Michael Kaufmann <mail@michael-kaufmann.ch> | 2018-02-05 22:02:10 +0100 |
commit | d25b0503795f1fbf557632ce870298f52f2a78c1 (patch) | |
tree | f3e73d71451c73ab3d6e39b71a057de92edd91b9 /src/tool_getparam.c | |
parent | 84ad1fd3047815f9c6e78728bb351b828eac10b1 (diff) | |
download | curl-d25b0503795f1fbf557632ce870298f52f2a78c1.tar.gz |
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
Diffstat (limited to 'src/tool_getparam.c')
-rw-r--r-- | src/tool_getparam.c | 17 |
1 files changed, 9 insertions, 8 deletions
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 */ |