mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Declare endian read functions argument as a const pointer.
This is done for all functions of the form Curl_read[136][624]_[lb]e.
This commit is contained in:
parent
945f60e8a7
commit
8034d8fc62
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
* Returns the integer.
|
* Returns the integer.
|
||||||
*/
|
*/
|
||||||
unsigned short Curl_read16_le(unsigned char *buf)
|
unsigned short Curl_read16_le(const unsigned char *buf)
|
||||||
{
|
{
|
||||||
return (unsigned short)(((unsigned short)buf[0]) |
|
return (unsigned short)(((unsigned short)buf[0]) |
|
||||||
((unsigned short)buf[1] << 8));
|
((unsigned short)buf[1] << 8));
|
||||||
@ -56,7 +56,7 @@ unsigned short Curl_read16_le(unsigned char *buf)
|
|||||||
*
|
*
|
||||||
* Returns the integer.
|
* Returns the integer.
|
||||||
*/
|
*/
|
||||||
unsigned int Curl_read32_le(unsigned char *buf)
|
unsigned int Curl_read32_le(const unsigned char *buf)
|
||||||
{
|
{
|
||||||
return ((unsigned int)buf[0]) | ((unsigned int)buf[1] << 8) |
|
return ((unsigned int)buf[0]) | ((unsigned int)buf[1] << 8) |
|
||||||
((unsigned int)buf[2] << 16) | ((unsigned int)buf[3] << 24);
|
((unsigned int)buf[2] << 16) | ((unsigned int)buf[3] << 24);
|
||||||
@ -77,7 +77,7 @@ unsigned int Curl_read32_le(unsigned char *buf)
|
|||||||
* Returns the integer.
|
* Returns the integer.
|
||||||
*/
|
*/
|
||||||
#if defined(HAVE_LONGLONG)
|
#if defined(HAVE_LONGLONG)
|
||||||
unsigned long long Curl_read64_le(unsigned char *buf)
|
unsigned long long Curl_read64_le(const unsigned char *buf)
|
||||||
{
|
{
|
||||||
return ((unsigned long long)buf[0]) |
|
return ((unsigned long long)buf[0]) |
|
||||||
((unsigned long long)buf[1] << 8) |
|
((unsigned long long)buf[1] << 8) |
|
||||||
@ -89,7 +89,7 @@ unsigned long long Curl_read64_le(unsigned char *buf)
|
|||||||
((unsigned long long)buf[7] << 56);
|
((unsigned long long)buf[7] << 56);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
unsigned __int64 Curl_read64_le(unsigned char *buf)
|
unsigned __int64 Curl_read64_le(const unsigned char *buf)
|
||||||
{
|
{
|
||||||
return ((unsigned __int64)buf[0]) | ((unsigned __int64)buf[1] << 8) |
|
return ((unsigned __int64)buf[0]) | ((unsigned __int64)buf[1] << 8) |
|
||||||
((unsigned __int64)buf[2] << 16) | ((unsigned __int64)buf[3] << 24) |
|
((unsigned __int64)buf[2] << 16) | ((unsigned __int64)buf[3] << 24) |
|
||||||
@ -113,7 +113,7 @@ unsigned __int64 Curl_read64_le(unsigned char *buf)
|
|||||||
*
|
*
|
||||||
* Returns the integer.
|
* Returns the integer.
|
||||||
*/
|
*/
|
||||||
unsigned short Curl_read16_be(unsigned char *buf)
|
unsigned short Curl_read16_be(const unsigned char *buf)
|
||||||
{
|
{
|
||||||
return (unsigned short)(((unsigned short)buf[0] << 8) |
|
return (unsigned short)(((unsigned short)buf[0] << 8) |
|
||||||
((unsigned short)buf[1]));
|
((unsigned short)buf[1]));
|
||||||
@ -132,7 +132,7 @@ unsigned short Curl_read16_be(unsigned char *buf)
|
|||||||
*
|
*
|
||||||
* Returns the integer.
|
* Returns the integer.
|
||||||
*/
|
*/
|
||||||
unsigned int Curl_read32_be(unsigned char *buf)
|
unsigned int Curl_read32_be(const unsigned char *buf)
|
||||||
{
|
{
|
||||||
return ((unsigned int)buf[0] << 24) | ((unsigned int)buf[1] << 16) |
|
return ((unsigned int)buf[0] << 24) | ((unsigned int)buf[1] << 16) |
|
||||||
((unsigned int)buf[2] << 8) | ((unsigned int)buf[3]);
|
((unsigned int)buf[2] << 8) | ((unsigned int)buf[3]);
|
||||||
@ -153,7 +153,7 @@ unsigned int Curl_read32_be(unsigned char *buf)
|
|||||||
* Returns the integer.
|
* Returns the integer.
|
||||||
*/
|
*/
|
||||||
#if defined(HAVE_LONGLONG)
|
#if defined(HAVE_LONGLONG)
|
||||||
unsigned long long Curl_read64_be(unsigned char *buf)
|
unsigned long long Curl_read64_be(const unsigned char *buf)
|
||||||
{
|
{
|
||||||
return ((unsigned long long)buf[0] << 56) |
|
return ((unsigned long long)buf[0] << 56) |
|
||||||
((unsigned long long)buf[1] << 48) |
|
((unsigned long long)buf[1] << 48) |
|
||||||
@ -165,7 +165,7 @@ unsigned long long Curl_read64_be(unsigned char *buf)
|
|||||||
((unsigned long long)buf[7]);
|
((unsigned long long)buf[7]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
unsigned __int64 Curl_read64_be(unsigned char *buf)
|
unsigned __int64 Curl_read64_be(const unsigned char *buf)
|
||||||
{
|
{
|
||||||
return ((unsigned __int64)buf[0] << 56) | ((unsigned __int64)buf[1] << 48) |
|
return ((unsigned __int64)buf[0] << 56) | ((unsigned __int64)buf[1] << 48) |
|
||||||
((unsigned __int64)buf[2] << 40) | ((unsigned __int64)buf[3] << 32) |
|
((unsigned __int64)buf[2] << 40) | ((unsigned __int64)buf[3] << 32) |
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -23,32 +23,32 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/* Converts a 16-bit integer from little endian */
|
/* Converts a 16-bit integer from little endian */
|
||||||
unsigned short Curl_read16_le(unsigned char *buf);
|
unsigned short Curl_read16_le(const unsigned char *buf);
|
||||||
|
|
||||||
/* Converts a 32-bit integer from little endian */
|
/* Converts a 32-bit integer from little endian */
|
||||||
unsigned int Curl_read32_le(unsigned char *buf);
|
unsigned int Curl_read32_le(const unsigned char *buf);
|
||||||
|
|
||||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||||
/* Converts a 64-bit integer from little endian */
|
/* Converts a 64-bit integer from little endian */
|
||||||
#if defined(HAVE_LONGLONG)
|
#if defined(HAVE_LONGLONG)
|
||||||
unsigned long long Curl_read64_le(unsigned char *buf);
|
unsigned long long Curl_read64_le(const unsigned char *buf);
|
||||||
#else
|
#else
|
||||||
unsigned __int64 Curl_read64_le(unsigned char *buf);
|
unsigned __int64 Curl_read64_le(const unsigned char *buf);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Converts a 16-bit integer from big endian */
|
/* Converts a 16-bit integer from big endian */
|
||||||
unsigned short Curl_read16_be(unsigned char *buf);
|
unsigned short Curl_read16_be(const unsigned char *buf);
|
||||||
|
|
||||||
/* Converts a 32-bit integer from big endian */
|
/* Converts a 32-bit integer from big endian */
|
||||||
unsigned int Curl_read32_be(unsigned char *buf);
|
unsigned int Curl_read32_be(const unsigned char *buf);
|
||||||
|
|
||||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||||
/* Converts a 64-bit integer from big endian */
|
/* Converts a 64-bit integer from big endian */
|
||||||
#if defined(HAVE_LONGLONG)
|
#if defined(HAVE_LONGLONG)
|
||||||
unsigned long long Curl_read64_be(unsigned char *buf);
|
unsigned long long Curl_read64_be(const unsigned char *buf);
|
||||||
#else
|
#else
|
||||||
unsigned __int64 Curl_read64_be(unsigned char *buf);
|
unsigned __int64 Curl_read64_be(const unsigned char *buf);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
14
lib/smb.c
14
lib/smb.c
@ -6,7 +6,7 @@
|
|||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
|
* Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
|
||||||
* Copyright (C) 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -308,8 +308,8 @@ static CURLcode smb_recv_message(struct connectdata *conn, void **msg)
|
|||||||
if(smbc->got < sizeof(unsigned int))
|
if(smbc->got < sizeof(unsigned int))
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
nbt_size = Curl_read16_be((unsigned char *)(buf + sizeof(unsigned short))) +
|
nbt_size = Curl_read16_be((const unsigned char *)(buf +
|
||||||
sizeof(unsigned int);
|
sizeof(unsigned short))) + sizeof(unsigned int);
|
||||||
if(smbc->got < nbt_size)
|
if(smbc->got < nbt_size)
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ static CURLcode smb_recv_message(struct connectdata *conn, void **msg)
|
|||||||
if(nbt_size >= msg_size + sizeof(unsigned short)) {
|
if(nbt_size >= msg_size + sizeof(unsigned short)) {
|
||||||
/* Add the byte count */
|
/* Add the byte count */
|
||||||
msg_size += sizeof(unsigned short) +
|
msg_size += sizeof(unsigned short) +
|
||||||
Curl_read16_le((unsigned char *)&buf[msg_size]);
|
Curl_read16_le((const unsigned char *)&buf[msg_size]);
|
||||||
if(nbt_size < msg_size)
|
if(nbt_size < msg_size)
|
||||||
return CURLE_READ_ERROR;
|
return CURLE_READ_ERROR;
|
||||||
}
|
}
|
||||||
@ -781,9 +781,9 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
|
|||||||
next_state = SMB_CLOSE;
|
next_state = SMB_CLOSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len = Curl_read16_le(((unsigned char *) msg) +
|
len = Curl_read16_le(((const unsigned char *) msg) +
|
||||||
sizeof(struct smb_header) + 11);
|
sizeof(struct smb_header) + 11);
|
||||||
off = Curl_read16_le(((unsigned char *) msg) +
|
off = Curl_read16_le(((const unsigned char *) msg) +
|
||||||
sizeof(struct smb_header) + 13);
|
sizeof(struct smb_header) + 13);
|
||||||
if(len > 0) {
|
if(len > 0) {
|
||||||
if(off + sizeof(unsigned int) + len > smbc->got) {
|
if(off + sizeof(unsigned int) + len > smbc->got) {
|
||||||
@ -812,7 +812,7 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
|
|||||||
next_state = SMB_CLOSE;
|
next_state = SMB_CLOSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len = Curl_read16_le(((unsigned char *) msg) +
|
len = Curl_read16_le(((const unsigned char *) msg) +
|
||||||
sizeof(struct smb_header) + 5);
|
sizeof(struct smb_header) + 5);
|
||||||
conn->data->req.bytecount += len;
|
conn->data->req.bytecount += len;
|
||||||
conn->data->req.offset += len;
|
conn->data->req.offset += len;
|
||||||
|
Loading…
Reference in New Issue
Block a user