0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00

Fix various problems with implicit size_t casts

All of these cases are safe casts since the
value is checked before-hand. So convert them
to explicit casts.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
This commit is contained in:
Frank Lichtenheld 2023-06-16 18:21:20 +02:00
parent 6b222bccd8
commit dabc3a0009
3 changed files with 11 additions and 10 deletions

View File

@ -166,9 +166,10 @@ class NTLM
add_security_buffer(0x1c, domain.c_str(), domain.size(), phase3);
// other security buffers will be empty
phase3[0x10] = phase3.size(); // lm not used
phase3[0x30] = phase3.size(); // no workstation name supplied
phase3[0x38] = phase3.size(); // no session key
const unsigned char phase3_size = static_cast<unsigned char>(phase3.size());
phase3[0x10] = phase3_size; // lm not used
phase3[0x30] = phase3_size; // no workstation name supplied
phase3[0x38] = phase3_size; // no session key
// flags
phase3[0x3c] = 0x02; // negotiate oem

View File

@ -1334,11 +1334,11 @@ class ProtoContext
{
if (size > 0xFFFF)
throw proto_error("auth_string_overflow");
const std::uint16_t net_size = htons(size);
const std::uint16_t net_size = htons(static_cast<std::uint16_t>(size));
buf.write((const unsigned char *)&net_size, sizeof(net_size));
}
static size_t read_uint16_length(Buffer &buf)
static uint16_t read_uint16_length(Buffer &buf)
{
if (buf.size())
{

View File

@ -235,11 +235,11 @@ class Sender
std::uint8_t len8;
if (len <= 125)
len8 = len;
len8 = static_cast<std::uint8_t>(len);
else if (len <= 65535)
{
len8 = 126;
const std::uint16_t len16 = htons(len);
const std::uint16_t len16 = htons(static_cast<std::uint16_t>(len));
buf.prepend(&len16, sizeof(len16));
}
else
@ -271,7 +271,7 @@ class Receiver
verify_message_complete();
if (size > buf.size())
throw websocket_error("Receiver::buf_unframed: internal error");
return Buffer(buf.data(), size, true);
return Buffer(buf.data(), static_cast<size_t>(size), true);
}
// return true if message is complete
@ -363,7 +363,7 @@ class Receiver
{
if (size < buf.size())
{
buf.advance(size);
buf.advance(static_cast<size_t>(size));
buf.realign(0);
}
else if (size == buf.size())
@ -397,7 +397,7 @@ class Receiver
// un-xor the data on the server side only
if (!is_client)
{
Buffer b(buf.data(), size, true);
Buffer b(buf.data(), static_cast<size_t>(size), true);
const Protocol::MaskingKey mk(mask);
mk.xor_buf(b);
}