time: support > year 2038 time stamps for system with 32bit long

... with the introduction of CURLOPT_TIMEVALUE_LARGE and
CURLINFO_FILETIME_T.

Fixes #2238
Closes #2264
This commit is contained in:
Daniel Stenberg 2018-01-25 23:05:24 +01:00
parent 9caa3e248d
commit 8f69a9f28a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
14 changed files with 193 additions and 21 deletions

View file

@ -438,7 +438,7 @@
# define TIME_T_MIN 0
# else
# define TIME_T_MAX 0x7FFFFFFFFFFFFFFF
# define TIME_T_MIN -0x10000000000000000
# define TIME_T_MIN (-TIME_T_MAX - 1)
# endif
#endif

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -156,7 +156,12 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
*param_longp = data->info.httpproxycode;
break;
case CURLINFO_FILETIME:
*param_longp = data->info.filetime;
if(data->info.filetime > LONG_MAX)
*param_longp = LONG_MAX;
else if(data->info.filetime < LONG_MIN)
*param_longp = LONG_MIN;
else
*param_longp = (long)data->info.filetime;
break;
case CURLINFO_HEADER_SIZE:
*param_longp = data->info.header_size;
@ -253,6 +258,9 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
curl_off_t *param_offt)
{
switch(info) {
case CURLINFO_FILETIME_T:
*param_offt = (curl_off_t)data->info.filetime;
break;
case CURLINFO_SIZE_UPLOAD_T:
*param_offt = data->progress.uploaded;
break;

View file

@ -361,6 +361,14 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
data->set.timevalue = (time_t)va_arg(param, long);
break;
case CURLOPT_TIMEVALUE_LARGE:
/*
* This is the value to compare with the remote document with the
* method set with CURLOPT_TIMECONDITION
*/
data->set.timevalue = (time_t)va_arg(param, curl_off_t);
break;
case CURLOPT_SSLVERSION:
case CURLOPT_PROXY_SSLVERSION:
/*

View file

@ -709,14 +709,19 @@ static CURLcode smb_connection_state(struct connectdata *conn, bool *done)
}
/*
* Convert a timestamp from the Windows world (100 nsec units from
* 1 Jan 1601) to Posix time.
* Convert a timestamp from the Windows world (100 nsec units from 1 Jan 1601)
* to Posix time. Cap the output to fit within a time_t.
*/
static void get_posix_time(long *out, curl_off_t timestamp)
static void get_posix_time(time_t *out, curl_off_t timestamp)
{
timestamp -= 116444736000000000;
timestamp /= 10000000;
*out = (long) timestamp;
if(timestamp > TIME_T_MAX)
*out = TIME_T_MAX;
else if(timestamp < TIME_T_MIN)
*out = TIME_T_MIN;
else
*out = (time_t) timestamp;
}
static CURLcode smb_request_state(struct connectdata *conn, bool *done)

View file

@ -1024,10 +1024,8 @@ struct PureInfo {
int httpcode; /* Recent HTTP, FTP, RTSP or SMTP response code */
int httpproxycode; /* response code from proxy when received separate */
int httpversion; /* the http version number X.Y = X*10+Y */
long filetime; /* If requested, this is might get set. Set to -1 if the time
was unretrievable. We cannot have this of type time_t,
since time_t is unsigned on several platforms such as
OpenVMS. */
time_t filetime; /* If requested, this is might get set. Set to -1 if the
time was unretrievable. */
bool timecond; /* set to TRUE if the time condition didn't match, which
thus made the document NOT get fetched */
long header_size; /* size of read header(s) in bytes */