summaryrefslogtreecommitdiff
path: root/lib/smb.c
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/smb.c
parent9caa3e248da91dc8964328b5b50491ba05df7bd4 (diff)
downloadcurl-8f69a9f28abf98a10a50b3bae5ba319660de82ee.tar.gz
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/smb.c')
-rw-r--r--lib/smb.c13
1 files changed, 9 insertions, 4 deletions
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)