aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-01-25 23:05:24 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-01-30 08:29:59 +0100
commit8f69a9f28abf98a10a50b3bae5ba319660de82ee (patch)
tree2b0eea6d076cd97763f0ce5dde7feed742cfe142 /lib
parent9caa3e248da91dc8964328b5b50491ba05df7bd4 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/curl_setup.h2
-rw-r--r--lib/getinfo.c12
-rw-r--r--lib/setopt.c8
-rw-r--r--lib/smb.c13
-rw-r--r--lib/urldata.h6
5 files changed, 30 insertions, 11 deletions
diff --git a/lib/curl_setup.h b/lib/curl_setup.h
index 100b8d40f..ecc0bb3df 100644
--- a/lib/curl_setup.h
+++ b/lib/curl_setup.h
@@ -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
diff --git a/lib/getinfo.c b/lib/getinfo.c
index 862ced019..d280eebfa 100644
--- a/lib/getinfo.c
+++ b/lib/getinfo.c
@@ -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;
diff --git a/lib/setopt.c b/lib/setopt.c
index a5ef75c72..686e9dbce 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -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:
/*
diff --git a/lib/smb.c b/lib/smb.c
index 6cb4083bb..e5ac5d76a 100644
--- a/lib/smb.c
+++ b/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)
diff --git a/lib/urldata.h b/lib/urldata.h
index 5c04ad172..6c594fe8d 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -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 */