mirror of
https://github.com/curl/curl.git
synced 2026-08-25 04:53:31 +03:00
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:
parent
9caa3e248d
commit
8f69a9f28a
14 changed files with 193 additions and 21 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
/*
|
||||
|
|
|
|||
13
lib/smb.c
13
lib/smb.c
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue