From 8f69a9f28abf98a10a50b3bae5ba319660de82ee Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 25 Jan 2018 23:05:24 +0100 Subject: 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 --- lib/smb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/smb.c') 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) -- cgit v1.2.3