diff options
author | Brad King <brad.king@kitware.com> | 2018-05-18 14:16:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-05-18 14:16:50 (GMT) |
commit | 3e913b819d8d8118d5e8dc3b7289f622e9ca92e5 (patch) | |
tree | 82c19f5ec814c84b986e54e3fc6fa0a83622fd81 /Utilities/cmcurl/lib/smb.c | |
parent | f3c73b878c594d40119e480ca1074e733d7ba1ce (diff) | |
parent | d431136e029c652f5913bcebeaab3b9236b114c4 (diff) | |
download | CMake-3e913b819d8d8118d5e8dc3b7289f622e9ca92e5.zip CMake-3e913b819d8d8118d5e8dc3b7289f622e9ca92e5.tar.gz CMake-3e913b819d8d8118d5e8dc3b7289f622e9ca92e5.tar.bz2 |
Merge branch 'upstream-curl' into update-curl
* upstream-curl:
curl 2018-05-15 (cb013830)
Diffstat (limited to 'Utilities/cmcurl/lib/smb.c')
-rw-r--r-- | Utilities/cmcurl/lib/smb.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/Utilities/cmcurl/lib/smb.c b/Utilities/cmcurl/lib/smb.c index 6cb4083..9ac6150 100644 --- a/Utilities/cmcurl/lib/smb.c +++ b/Utilities/cmcurl/lib/smb.c @@ -709,14 +709,21 @@ 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 SIZEOF_TIME_T < SIZEOF_CURL_OFF_T + if(timestamp > TIME_T_MAX) + *out = TIME_T_MAX; + else if(timestamp < TIME_T_MIN) + *out = TIME_T_MIN; + else +#endif + *out = (time_t) timestamp; } static CURLcode smb_request_state(struct connectdata *conn, bool *done) @@ -783,10 +790,16 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done) else { smb_m = (const struct smb_nt_create_response*) msg; conn->data->req.size = smb_swap64(smb_m->end_of_file); - Curl_pgrsSetDownloadSize(conn->data, conn->data->req.size); - if(conn->data->set.get_filetime) - get_posix_time(&conn->data->info.filetime, smb_m->last_change_time); - next_state = SMB_DOWNLOAD; + if(conn->data->req.size < 0) { + req->result = CURLE_WEIRD_SERVER_REPLY; + next_state = SMB_CLOSE; + } + else { + Curl_pgrsSetDownloadSize(conn->data, conn->data->req.size); + if(conn->data->set.get_filetime) + get_posix_time(&conn->data->info.filetime, smb_m->last_change_time); + next_state = SMB_DOWNLOAD; + } } break; |