Merge pull request #10677 from akallabeth/int-narrow

Int narrow
This commit is contained in:
akallabeth
2024-10-03 21:17:56 +02:00
committed by GitHub
31 changed files with 233 additions and 308 deletions

View File

@@ -457,7 +457,7 @@ static UINT rdpdr_process_client_name_request(pf_channel_server_context* rdpdr,
return ERROR_INVALID_DATA;
Stream_Read_UINT32(s, unicodeFlag);
rdpdr->common.computerNameUnicode = (unicodeFlag & 1);
rdpdr->common.computerNameUnicode = ((unicodeFlag & 1) != 0) ? TRUE : FALSE;
Stream_Read_UINT32(s, codePage);
WINPR_UNUSED(codePage); /* Field is ignored */

View File

@@ -24,6 +24,7 @@
#include <fstream>
#include <iostream>
#include <regex>
#include <limits>
#include <utility>
#include <vector>
#include <sstream>
@@ -332,7 +333,13 @@ static BOOL dump_dyn_channel_intercept(proxyPlugin* plugin, proxyData* pdata, vo
WLog_ERR(TAG, "Could not write to stream");
return FALSE;
}
stream.write(buffer, Stream_Length(data->data));
const auto s = Stream_Length(data->data);
if (s > std::numeric_limits<std::streamsize>::max())
{
WLog_ERR(TAG, "Stream length %" PRIuz " exceeds std::streamsize::max", s);
return FALSE;
}
stream.write(buffer, static_cast<std::streamsize>(s));
if (stream.fail())
{
WLog_ERR(TAG, "Could not write to stream");

View File

@@ -94,8 +94,8 @@ PfChannelResult channelTracker_update(ChannelStateTracker* tracker, const BYTE*
UINT32 flags, size_t totalSize)
{
PfChannelResult result = PF_CHANNEL_RESULT_ERROR;
BOOL firstPacket = (flags & CHANNEL_FLAG_FIRST);
BOOL lastPacket = (flags & CHANNEL_FLAG_LAST);
BOOL firstPacket = (flags & CHANNEL_FLAG_FIRST) != 0;
BOOL lastPacket = (flags & CHANNEL_FLAG_LAST) != 0;
WINPR_ASSERT(tracker);

View File

@@ -73,7 +73,10 @@ BOOL shadow_client_audin_init(rdpShadowClient* client)
if (client->subsystem->audinFormats)
{
if (!audin_server_set_formats(client->audin, client->subsystem->nAudinFormats,
if (client->subsystem->nAudinFormats > SSIZE_MAX)
goto fail;
if (!audin_server_set_formats(client->audin, (SSIZE_T)client->subsystem->nAudinFormats,
client->subsystem->audinFormats))
goto fail;
}

View File

@@ -804,7 +804,8 @@ static BOOL shadow_server_create_certificate(rdpShadowServer* server, const char
if (!makecert)
goto out_fail;
if (makecert_context_process(makecert, makecert_argc, makecert_argv) < 0)
WINPR_ASSERT(makecert_argc <= INT_MAX);
if (makecert_context_process(makecert, (int)makecert_argc, makecert_argv) < 0)
goto out_fail;
if (makecert_context_set_output_file_name(makecert, "shadow") != 1)