summaryrefslogtreecommitdiff
path: root/lib/smb.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-01-15 20:43:34 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-01-16 22:21:59 +0100
commit25c40c9af97782c9d475e765d50eaac071fd7d91 (patch)
tree88b7dcaadc303bdd39362f9a60ba0f0c931ed9ac /lib/smb.c
parent945df74101140a336699f1de6616302d49ca7be8 (diff)
downloadcurl-25c40c9af97782c9d475e765d50eaac071fd7d91.tar.gz
SMB: fix numeric constant suffix and variable types
1. don't use "ULL" suffix since unsupported in older MSVC 2. use curl_off_t instead of custom long long ifdefs 3. make get_posix_time() not do unaligned data access Fixes #2211 Closes #2240 Reported-by: Chester Liu
Diffstat (limited to 'lib/smb.c')
-rw-r--r--lib/smb.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/lib/smb.c b/lib/smb.c
index efcfd2da2..6cb4083bb 100644
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
- * Copyright (C) 2016-2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2016-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
@@ -146,19 +146,12 @@ static unsigned int smb_swap32(unsigned int x)
((x >> 24) & 0xff);
}
-#ifdef HAVE_LONGLONG
-static unsigned long long smb_swap64(unsigned long long x)
+static curl_off_t smb_swap64(curl_off_t x)
{
- return ((unsigned long long) smb_swap32((unsigned int) x) << 32) |
+ return ((curl_off_t) smb_swap32((unsigned int) x) << 32) |
smb_swap32((unsigned int) (x >> 32));
}
-#else
-static unsigned __int64 smb_swap64(unsigned __int64 x)
-{
- return ((unsigned __int64) smb_swap32((unsigned int) x) << 32) |
- smb_swap32((unsigned int) (x >> 32));
-}
-#endif
+
#else
# define smb_swap16(x) (x)
# define smb_swap32(x) (x)
@@ -719,17 +712,11 @@ 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.
*/
-static void get_posix_time(long *_out, const void *_in)
+static void get_posix_time(long *out, curl_off_t timestamp)
{
-#ifdef HAVE_LONGLONG
- long long timestamp = *(long long *) _in;
-#else
- unsigned __int64 timestamp = *(unsigned __int64 *) _in;
-#endif
-
- timestamp -= 116444736000000000ULL;
+ timestamp -= 116444736000000000;
timestamp /= 10000000;
- *_out = (long) timestamp;
+ *out = (long) timestamp;
}
static CURLcode smb_request_state(struct connectdata *conn, bool *done)
@@ -798,7 +785,7 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
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);
+ get_posix_time(&conn->data->info.filetime, smb_m->last_change_time);
next_state = SMB_DOWNLOAD;
}
break;