[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 112/125: SMB: fix numeric constant suffix and varia
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 112/125: SMB: fix numeric constant suffix and variable types |
Date: |
Sun, 21 Jan 2018 23:42:47 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 25c40c9af97782c9d475e765d50eaac071fd7d91
Author: Daniel Stenberg <address@hidden>
AuthorDate: Mon Jan 15 20:43:34 2018 +0100
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
---
lib/smb.c | 29 ++++++++---------------------
lib/smb.h | 33 ++++++++++-----------------------
2 files changed, 18 insertions(+), 44 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 <address@hidden>, Exacq Technologies
- * Copyright (C) 2016-2017, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 2016-2018, Daniel Stenberg, <address@hidden>, 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;
diff --git a/lib/smb.h b/lib/smb.h
index 1a4f66e5a..c3ee7ae03 100644
--- a/lib/smb.h
+++ b/lib/smb.h
@@ -8,6 +8,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014, Bill Nagel <address@hidden>, Exacq Technologies
+ * Copyright (C) 2018, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -165,11 +166,7 @@ struct smb_nt_create {
unsigned int flags;
unsigned int root_fid;
unsigned int access;
-#ifdef HAVE_LONGLONG
- unsigned long long allocation_size;
-#else
- unsigned __int64 allocation_size;
-#endif
+ curl_off_t allocation_size;
unsigned int ext_file_attributes;
unsigned int share_access;
unsigned int create_disposition;
@@ -187,25 +184,15 @@ struct smb_nt_create_response {
unsigned char op_lock_level;
unsigned short fid;
unsigned int create_disposition;
-#ifdef HAVE_LONGLONG
- unsigned long long create_time;
- unsigned long long last_access_time;
- unsigned long long last_write_time;
- unsigned long long last_change_time;
-#else
- unsigned __int64 create_time;
- unsigned __int64 last_access_time;
- unsigned __int64 last_write_time;
- unsigned __int64 last_change_time;
-#endif
+
+ curl_off_t create_time;
+ curl_off_t last_access_time;
+ curl_off_t last_write_time;
+ curl_off_t last_change_time;
unsigned int ext_file_attributes;
-#ifdef HAVE_LONGLONG
- unsigned long long allocation_size;
- unsigned long long end_of_file;
-#else
- unsigned __int64 allocation_size;
- unsigned __int64 end_of_file;
-#endif
+ curl_off_t allocation_size;
+ curl_off_t end_of_file;
+
} PACK;
struct smb_read {
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 85/125: brotli: data at the end of content can be lost, (continued)
- [GNUnet-SVN] [gnurl] 85/125: brotli: data at the end of content can be lost, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 108/125: mime: clone mime tree upon easy handle duplication., gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 48/125: CURLOPT_DNS_CACHE_TIMEOUT.3: see also CURLOPT_RESOLVE, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 63/125: mailmap: added/clarified several names, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 25/125: conncache: fix several lock issues, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 67/125: curl: support >256 bytes warning messsages, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 99/125: setopt: reintroduce non-static Curl_vsetopt() for OS400 support, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 82/125: build: Fixed incorrect script termination from commit ad1dc10e61, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 92/125: mail-rcpt.d: fix short-text description, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 102/125: configure.ac: append extra linker flags instead of prepending them., gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 112/125: SMB: fix numeric constant suffix and variable types,
gnunet <=
- [GNUnet-SVN] [gnurl] 119/125: examples/url2file.c: add missing curl_global_cleanup() call, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 84/125: examples/cacertinmem: ignore cert-already-exists error, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 123/125: libcurl-env.3: first take, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 55/125: Revert "curl: don't set CURLOPT_INTERLEAVEDATA", gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 62/125: setopt: less *or equal* than INT_MAX/1000 should be fine, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 68/125: conncache: fix a return code [regression], gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 65/125: examples/smtp-mail.c: use separate defines for options and mail, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 125/125: Merge branch 'master' of https://github.com/curl/curl, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 81/125: Makefile.vc: Added our standard copyright header, gnunet, 2018/01/21
- [GNUnet-SVN] [gnurl] 73/125: content_encoding: rework zlib_inflate, gnunet, 2018/01/21