Merge pull request #10622 from akallabeth/warn-fx
[warnings] fix shorten-64-to-32
This commit is contained in:
commit
4d8a3a22e2
@ -61,6 +61,7 @@ Checks: >
|
||||
-modernize-return-braced-init-list,
|
||||
-modernize-macro-to-enum,
|
||||
-modernize-pass-by-value,
|
||||
-modernize-avoid-c-arrays,
|
||||
-readability-braces-around-statements,
|
||||
-readability-function-cognitive-complexity,
|
||||
-readability-identifier-length,
|
||||
|
@ -943,10 +943,10 @@ BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, const ADDIN_ARGV* args)
|
||||
{
|
||||
long val = strtol(arg->Value, NULL, 0);
|
||||
|
||||
if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
|
||||
if ((errno != 0) || (val == 0) || (val > UINT32_MAX))
|
||||
return FALSE;
|
||||
|
||||
audin->fixed_format->nSamplesPerSec = val;
|
||||
audin->fixed_format->nSamplesPerSec = (UINT32)val;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "channel")
|
||||
{
|
||||
|
@ -399,7 +399,9 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u
|
||||
buffer_attr.prebuf = (UINT32)-1;
|
||||
buffer_attr.minreq = (UINT32)-1;
|
||||
/* 500ms latency */
|
||||
buffer_attr.fragsize = pulse->bytes_per_frame * pulse->frames_per_packet;
|
||||
const size_t frag = pulse->bytes_per_frame * pulse->frames_per_packet;
|
||||
WINPR_ASSERT(frag <= UINT32_MAX);
|
||||
buffer_attr.fragsize = (uint32_t)frag;
|
||||
|
||||
if (buffer_attr.fragsize % pulse->format.nBlockAlign)
|
||||
buffer_attr.fragsize +=
|
||||
|
@ -403,14 +403,13 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
|
||||
}
|
||||
else if (!useLongFormatNames)
|
||||
{
|
||||
const size_t cap = Stream_Capacity(sub1);
|
||||
formatList->numFormats = (cap / 36ULL);
|
||||
|
||||
if ((36ULL * formatList->numFormats) != cap)
|
||||
const size_t cap = Stream_Capacity(sub1) / 36ULL;
|
||||
if (cap > UINT32_MAX)
|
||||
{
|
||||
WLog_ERR(TAG, "Invalid short format list length: %" PRIuz "", cap);
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
}
|
||||
formatList->numFormats = (UINT32)cap;
|
||||
|
||||
if (formatList->numFormats)
|
||||
formats = (CLIPRDR_FORMAT*)calloc(formatList->numFormats, sizeof(CLIPRDR_FORMAT));
|
||||
|
@ -311,7 +311,11 @@ static UINT disp_server_handle_messages(DispServerContext* context)
|
||||
return CHANNEL_RC_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (WTSVirtualChannelRead(priv->disp_channel, 0, (PCHAR)Stream_Buffer(s), Stream_Capacity(s),
|
||||
const size_t cap = Stream_Capacity(s);
|
||||
if (cap > UINT32_MAX)
|
||||
return CHANNEL_RC_NO_BUFFER;
|
||||
|
||||
if (WTSVirtualChannelRead(priv->disp_channel, 0, (PCHAR)Stream_Buffer(s), (ULONG)cap,
|
||||
&BytesReturned) == FALSE)
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
@ -488,8 +492,15 @@ static UINT disp_server_packet_send(DispServerContext* context, wStream* s)
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
if (!WTSVirtualChannelWrite(context->priv->disp_channel, (PCHAR)Stream_Buffer(s),
|
||||
Stream_GetPosition(s), &written))
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
if (pos > UINT32_MAX)
|
||||
{
|
||||
ret = ERROR_INTERNAL_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!WTSVirtualChannelWrite(context->priv->disp_channel, (PCHAR)Stream_Buffer(s), pos,
|
||||
&written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
ret = ERROR_INTERNAL_ERROR;
|
||||
|
@ -470,7 +470,10 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
const size_t volumeLabelLen = (_wcslen(volumeLabel) + 1) * sizeof(WCHAR);
|
||||
const size_t length = 17ul + volumeLabelLen;
|
||||
|
||||
Stream_Write_UINT32(output, length); /* Length */
|
||||
if ((length > UINT32_MAX) || (volumeLabelLen > UINT32_MAX))
|
||||
return CHANNEL_RC_NO_BUFFER;
|
||||
|
||||
Stream_Write_UINT32(output, (UINT32)length); /* Length */
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(output, length))
|
||||
{
|
||||
@ -483,7 +486,7 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
Stream_Write_UINT32(output,
|
||||
wfad.ftCreationTime.dwHighDateTime); /* VolumeCreationTime */
|
||||
Stream_Write_UINT32(output, lpNumberOfFreeClusters & 0xffff); /* VolumeSerialNumber */
|
||||
Stream_Write_UINT32(output, volumeLabelLen); /* VolumeLabelLength */
|
||||
Stream_Write_UINT32(output, (UINT32)volumeLabelLen); /* VolumeLabelLength */
|
||||
Stream_Write_UINT8(output, 0); /* SupportsObjects */
|
||||
/* Reserved(1), MUST NOT be added! */
|
||||
Stream_Write(output, volumeLabel, volumeLabelLen); /* VolumeLabel (Unicode) */
|
||||
@ -513,7 +516,11 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
InitializeConstWCharFromUtf8("FAT32", LabelBuffer, ARRAYSIZE(LabelBuffer));
|
||||
const size_t diskTypeLen = (_wcslen(diskType) + 1) * sizeof(WCHAR);
|
||||
const size_t length = 12ul + diskTypeLen;
|
||||
Stream_Write_UINT32(output, length); /* Length */
|
||||
|
||||
if ((length > UINT32_MAX) || (diskTypeLen > UINT32_MAX))
|
||||
return CHANNEL_RC_NO_BUFFER;
|
||||
|
||||
Stream_Write_UINT32(output, (UINT32)length); /* Length */
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(output, length))
|
||||
{
|
||||
@ -524,7 +531,7 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
Stream_Write_UINT32(output, FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES |
|
||||
FILE_UNICODE_ON_DISK); /* FileSystemAttributes */
|
||||
Stream_Write_UINT32(output, MAX_PATH); /* MaximumComponentNameLength */
|
||||
Stream_Write_UINT32(output, diskTypeLen); /* FileSystemNameLength */
|
||||
Stream_Write_UINT32(output, (UINT32)diskTypeLen); /* FileSystemNameLength */
|
||||
Stream_Write(output, diskType, diskTypeLen); /* FileSystemName (Unicode) */
|
||||
}
|
||||
break;
|
||||
|
@ -249,8 +249,10 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
|
||||
Stream_Capacity(s), &BytesReturned))
|
||||
const size_t cap = Stream_Capacity(s);
|
||||
if ((cap > UINT32_MAX) ||
|
||||
!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s),
|
||||
(ULONG)cap, &BytesReturned))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
error = ERROR_INTERNAL_ERROR;
|
||||
|
@ -99,12 +99,15 @@ static BOOL location_read_server_ready_pdu(LOCATION_CALLBACK* callback, wStream*
|
||||
static UINT location_channel_send(IWTSVirtualChannel* channel, wStream* s)
|
||||
{
|
||||
const size_t len = Stream_GetPosition(s);
|
||||
if (len > UINT32_MAX)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
||||
Stream_SetPosition(s, 2);
|
||||
Stream_Write_UINT32(s, len);
|
||||
Stream_Write_UINT32(s, (UINT32)len);
|
||||
|
||||
WINPR_ASSERT(channel);
|
||||
WINPR_ASSERT(channel->Write);
|
||||
return channel->Write(channel, len, Stream_Buffer(s), NULL);
|
||||
return channel->Write(channel, (UINT32)len, Stream_Buffer(s), NULL);
|
||||
}
|
||||
|
||||
static UINT location_send_client_ready_pdu(const LOCATION_CALLBACK* callback)
|
||||
|
@ -541,8 +541,11 @@ static UINT location_server_packet_send(LocationServerContext* context, wStream*
|
||||
WINPR_ASSERT(location);
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
if (!WTSVirtualChannelWrite(location->location_channel, (PCHAR)Stream_Buffer(s),
|
||||
Stream_GetPosition(s), &written))
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
if (pos > UINT32_MAX)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
if (!WTSVirtualChannelWrite(location->location_channel, (PCHAR)Stream_Buffer(s), (ULONG)pos,
|
||||
&written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
error = ERROR_INTERNAL_ERROR;
|
||||
|
@ -169,7 +169,7 @@ static UINT parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
|
||||
status = read(parallel->file, buffer, Length);
|
||||
|
||||
if (status < 0)
|
||||
if ((status < 0) || (status > UINT32_MAX))
|
||||
{
|
||||
irp->IoStatus = STATUS_UNSUCCESSFUL;
|
||||
free(buffer);
|
||||
@ -178,7 +178,7 @@ static UINT parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
}
|
||||
else
|
||||
{
|
||||
Length = status;
|
||||
Length = (UINT32)status;
|
||||
}
|
||||
|
||||
Stream_Write_UINT32(irp->output, Length);
|
||||
|
@ -622,8 +622,12 @@ UINT rdpei_server_send_sc_ready(RdpeiServerContext* context, UINT32 version, UIN
|
||||
if (version >= RDPINPUT_PROTOCOL_V300)
|
||||
Stream_Write_UINT32(priv->outputStream, features);
|
||||
|
||||
const size_t pos = Stream_GetPosition(priv->outputStream);
|
||||
if (pos > UINT32_MAX)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
||||
if (!WTSVirtualChannelWrite(priv->channelHandle, (PCHAR)Stream_Buffer(priv->outputStream),
|
||||
Stream_GetPosition(priv->outputStream), &written))
|
||||
(ULONG)pos, &written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -665,8 +669,12 @@ UINT rdpei_server_suspend(RdpeiServerContext* context)
|
||||
Stream_Write_UINT16(priv->outputStream, EVENTID_SUSPEND_TOUCH);
|
||||
Stream_Write_UINT32(priv->outputStream, RDPINPUT_HEADER_LENGTH);
|
||||
|
||||
const size_t pos = Stream_GetPosition(priv->outputStream);
|
||||
if (pos > UINT32_MAX)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
||||
if (!WTSVirtualChannelWrite(priv->channelHandle, (PCHAR)Stream_Buffer(priv->outputStream),
|
||||
Stream_GetPosition(priv->outputStream), &written))
|
||||
(ULONG)pos, &written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -708,8 +716,12 @@ UINT rdpei_server_resume(RdpeiServerContext* context)
|
||||
Stream_Write_UINT16(priv->outputStream, EVENTID_RESUME_TOUCH);
|
||||
Stream_Write_UINT32(priv->outputStream, RDPINPUT_HEADER_LENGTH);
|
||||
|
||||
const size_t pos = Stream_GetPosition(priv->outputStream);
|
||||
if (pos > UINT32_MAX)
|
||||
return CHANNEL_RC_NO_BUFFER;
|
||||
|
||||
if (!WTSVirtualChannelWrite(priv->channelHandle, (PCHAR)Stream_Buffer(priv->outputStream),
|
||||
Stream_GetPosition(priv->outputStream), &written))
|
||||
(ULONG)pos, &written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
@ -511,8 +511,11 @@ static UINT mouse_cursor_server_packet_send(MouseCursorServerContext* context, w
|
||||
WINPR_ASSERT(mouse_cursor);
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
if (pos > UINT32_MAX)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
if (!WTSVirtualChannelWrite(mouse_cursor->mouse_cursor_channel, (PCHAR)Stream_Buffer(s),
|
||||
Stream_GetPosition(s), &written))
|
||||
(ULONG)pos, &written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
error = ERROR_INTERNAL_ERROR;
|
||||
|
@ -455,7 +455,7 @@ static UINT rdpsnd_alsa_play(rdpsndDevicePlugin* device, const BYTE* data, size_
|
||||
int rc = snd_pcm_avail_delay(alsa->pcm_handle, &available, &delay);
|
||||
|
||||
if ((rc == 0) && (available == 0)) /* Get [ms] from number of samples */
|
||||
latency = delay * 1000 / alsa->actual_rate;
|
||||
latency = (UINT32)MIN(UINT32_MAX, delay * 1000 / alsa->actual_rate);
|
||||
}
|
||||
|
||||
return latency + alsa->latency;
|
||||
|
@ -26,7 +26,10 @@ SDL_RWops* SDL2ResourceManager::get(const std::string& type, const std::string&
|
||||
if (!d)
|
||||
return nullptr;
|
||||
|
||||
return SDL_RWFromConstMem(d->data(), d->size());
|
||||
auto s = d->size();
|
||||
if (s > INT32_MAX)
|
||||
return nullptr;
|
||||
return SDL_RWFromConstMem(d->data(), static_cast<int>(s));
|
||||
}
|
||||
|
||||
auto name = filename(type, id);
|
||||
|
@ -1163,8 +1163,6 @@ wStream* fastpath_update_pdu_init_new(rdpFastPath* fastpath)
|
||||
BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s,
|
||||
BOOL skipCompression)
|
||||
{
|
||||
UINT16 maxLength = 0;
|
||||
UINT32 totalLength = 0;
|
||||
BOOL status = TRUE;
|
||||
wStream* fs = NULL;
|
||||
rdpSettings* settings = NULL;
|
||||
@ -1172,7 +1170,6 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
UINT32 fpHeaderSize = 6;
|
||||
UINT32 fpUpdatePduHeaderSize = 0;
|
||||
UINT32 fpUpdateHeaderSize = 0;
|
||||
UINT32 CompressionMaxSize = 0;
|
||||
FASTPATH_UPDATE_PDU_HEADER fpUpdatePduHeader = { 0 };
|
||||
FASTPATH_UPDATE_HEADER fpUpdateHeader = { 0 };
|
||||
|
||||
@ -1186,16 +1183,17 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
if (!settings)
|
||||
return FALSE;
|
||||
|
||||
maxLength = FASTPATH_MAX_PACKET_SIZE - 20;
|
||||
UINT16 maxLength = FASTPATH_MAX_PACKET_SIZE - 20;
|
||||
|
||||
if (settings->CompressionEnabled && !skipCompression)
|
||||
{
|
||||
CompressionMaxSize = bulk_compression_max_size(rdp->bulk);
|
||||
maxLength = (maxLength < CompressionMaxSize) ? maxLength : CompressionMaxSize;
|
||||
const UINT32 CompressionMaxSize = bulk_compression_max_size(rdp->bulk);
|
||||
maxLength =
|
||||
(maxLength < CompressionMaxSize) ? maxLength : MIN(CompressionMaxSize, UINT16_MAX);
|
||||
maxLength -= 20;
|
||||
}
|
||||
|
||||
totalLength = Stream_GetPosition(s);
|
||||
size_t totalLength = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
/* check if fast path output is possible */
|
||||
@ -1209,7 +1207,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
if (totalLength > settings->MultifragMaxRequestSize)
|
||||
{
|
||||
WLog_ERR(TAG,
|
||||
"fast path update size (%" PRIu32
|
||||
"fast path update size (%" PRIuz
|
||||
") exceeds the client's maximum request size (%" PRIu32 ")",
|
||||
totalLength, settings->MultifragMaxRequestSize);
|
||||
return FALSE;
|
||||
@ -1225,8 +1223,6 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
|
||||
for (int fragment = 0; (totalLength > 0) || (fragment == 0); fragment++)
|
||||
{
|
||||
const BYTE* pSrcData = NULL;
|
||||
UINT32 SrcSize = 0;
|
||||
UINT32 DstSize = 0;
|
||||
const BYTE* pDstData = NULL;
|
||||
UINT32 compressionFlags = 0;
|
||||
@ -1237,9 +1233,9 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
fpUpdateHeader.compression = 0;
|
||||
fpUpdateHeader.compressionFlags = 0;
|
||||
fpUpdateHeader.updateCode = updateCode;
|
||||
fpUpdateHeader.size = (totalLength > maxLength) ? maxLength : totalLength;
|
||||
pSrcData = Stream_Pointer(s);
|
||||
SrcSize = DstSize = fpUpdateHeader.size;
|
||||
fpUpdateHeader.size = (UINT16)(totalLength > maxLength) ? maxLength : totalLength;
|
||||
const BYTE* pSrcData = Stream_Pointer(s);
|
||||
UINT32 SrcSize = DstSize = fpUpdateHeader.size;
|
||||
|
||||
if (rdp->sec_flags & SEC_ENCRYPT)
|
||||
fpUpdatePduHeader.secFlags |= FASTPATH_OUTPUT_ENCRYPTED;
|
||||
|
@ -1393,32 +1393,43 @@ static BOOL rdp_write_logon_info_v1(wStream* s, logon_info* info)
|
||||
const size_t userCharLen = 512 / sizeof(WCHAR);
|
||||
|
||||
size_t sz = 4 + 52 + 4 + 512 + 4;
|
||||
size_t len = 0;
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, sz))
|
||||
return FALSE;
|
||||
|
||||
/* domain */
|
||||
WINPR_ASSERT(info);
|
||||
if (!info->domain || !info->username)
|
||||
return FALSE;
|
||||
{
|
||||
WINPR_ASSERT(info);
|
||||
if (!info->domain || !info->username)
|
||||
return FALSE;
|
||||
const size_t len = strnlen(info->domain, charLen + 1);
|
||||
if (len > charLen)
|
||||
return FALSE;
|
||||
|
||||
len = strnlen(info->domain, charLen + 1);
|
||||
if (len > charLen)
|
||||
return FALSE;
|
||||
const size_t wlen = len * sizeof(WCHAR);
|
||||
if (wlen > UINT32_MAX)
|
||||
return FALSE;
|
||||
|
||||
Stream_Write_UINT32(s, len * sizeof(WCHAR));
|
||||
if (Stream_Write_UTF16_String_From_UTF8(s, charLen, info->domain, len, TRUE) < 0)
|
||||
return FALSE;
|
||||
Stream_Write_UINT32(s, (UINT32)wlen);
|
||||
if (Stream_Write_UTF16_String_From_UTF8(s, charLen, info->domain, len, TRUE) < 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* username */
|
||||
len = strnlen(info->username, userCharLen + 1);
|
||||
if (len > userCharLen)
|
||||
return FALSE;
|
||||
{
|
||||
const size_t len = strnlen(info->username, userCharLen + 1);
|
||||
if (len > userCharLen)
|
||||
return FALSE;
|
||||
|
||||
Stream_Write_UINT32(s, len * sizeof(WCHAR));
|
||||
if (Stream_Write_UTF16_String_From_UTF8(s, userCharLen, info->username, len, TRUE) < 0)
|
||||
return FALSE;
|
||||
const size_t wlen = len * sizeof(WCHAR);
|
||||
if (wlen > UINT32_MAX)
|
||||
return FALSE;
|
||||
|
||||
Stream_Write_UINT32(s, (UINT32)wlen);
|
||||
|
||||
if (Stream_Write_UTF16_String_From_UTF8(s, userCharLen, info->username, len, TRUE) < 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* sessionId */
|
||||
Stream_Write_UINT32(s, info->sessionId);
|
||||
|
@ -884,7 +884,6 @@ static BOOL nego_read_request_token_or_cookie(rdpNego* nego, wStream* s)
|
||||
* Cookie:[space]mstshash=[ANSISTRING][\x0D\x0A]
|
||||
*/
|
||||
UINT16 crlf = 0;
|
||||
size_t len = 0;
|
||||
BOOL result = FALSE;
|
||||
BOOL isToken = FALSE;
|
||||
size_t remain = Stream_GetRemainingLength(s);
|
||||
@ -935,13 +934,16 @@ static BOOL nego_read_request_token_or_cookie(rdpNego* nego, wStream* s)
|
||||
if (crlf == 0x0A0D)
|
||||
{
|
||||
Stream_Rewind(s, 2);
|
||||
len = Stream_GetPosition(s) - pos;
|
||||
const size_t len = Stream_GetPosition(s) - pos;
|
||||
Stream_Write_UINT16(s, 0);
|
||||
|
||||
if (len > UINT32_MAX)
|
||||
return FALSE;
|
||||
|
||||
if (strnlen(str, len) == len)
|
||||
{
|
||||
if (isToken)
|
||||
result = nego_set_routing_token(nego, str, len);
|
||||
result = nego_set_routing_token(nego, str, (UINT32)len);
|
||||
else
|
||||
result = nego_set_cookie(nego, str);
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ static BOOL nla_client_setup_identity(rdpNla* nla)
|
||||
WINPR_SAM* sam = SamOpen(NULL, TRUE);
|
||||
if (sam)
|
||||
{
|
||||
const size_t userLength = strlen(settings->Username);
|
||||
const UINT32 userLength = (UINT32)strnlen(settings->Username, INT32_MAX);
|
||||
WINPR_SAM_ENTRY* entry = SamLookupUserA(
|
||||
sam, settings->Username, userLength + 1 /* ensure '\0' is checked too */, NULL, 0);
|
||||
if (entry)
|
||||
@ -1571,7 +1571,7 @@ static BOOL nla_encode_ts_credentials(rdpNla* nla)
|
||||
size_t len = 0;
|
||||
|
||||
octet_string.data = (BYTE*)freerdp_settings_get_string_as_utf16(
|
||||
settings, cspData_fields[i].setting_id, &len);
|
||||
settings, (FreeRDP_Settings_Keys_String)cspData_fields[i].setting_id, &len);
|
||||
octet_string.len = len * sizeof(WCHAR);
|
||||
if (octet_string.len)
|
||||
{
|
||||
|
@ -1531,27 +1531,22 @@ static BOOL update_send_play_sound(rdpContext* context, const PLAY_SOUND_UPDATE*
|
||||
|
||||
static BOOL update_send_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
|
||||
{
|
||||
wStream* s = NULL;
|
||||
size_t offset = 0;
|
||||
UINT32 headerLength = 0;
|
||||
ORDER_INFO orderInfo;
|
||||
int inf = 0;
|
||||
rdp_update_internal* update = NULL;
|
||||
ORDER_INFO orderInfo = { 0 };
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(dstblt);
|
||||
|
||||
update = update_cast(context->update);
|
||||
rdp_update_internal* update = update_cast(context->update);
|
||||
|
||||
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_DSTBLT);
|
||||
inf = update_approximate_dstblt_order(&orderInfo, dstblt);
|
||||
const int headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_DSTBLT);
|
||||
const size_t inf = update_approximate_dstblt_order(&orderInfo, dstblt);
|
||||
update_check_flush(context, headerLength + inf);
|
||||
s = update->us;
|
||||
wStream* s = update->us;
|
||||
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
offset = Stream_GetPosition(s);
|
||||
const size_t offset = Stream_GetPosition(s);
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
||||
return FALSE;
|
||||
@ -1599,26 +1594,21 @@ static BOOL update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt)
|
||||
|
||||
static BOOL update_send_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
|
||||
{
|
||||
wStream* s = NULL;
|
||||
UINT32 offset = 0;
|
||||
UINT32 headerLength = 0;
|
||||
ORDER_INFO orderInfo;
|
||||
int inf = 0;
|
||||
rdp_update_internal* update = NULL;
|
||||
ORDER_INFO orderInfo = { 0 };
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(scrblt);
|
||||
update = update_cast(context->update);
|
||||
rdp_update_internal* update = update_cast(context->update);
|
||||
|
||||
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_SCRBLT);
|
||||
inf = update_approximate_scrblt_order(&orderInfo, scrblt);
|
||||
const int headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_SCRBLT);
|
||||
const size_t inf = update_approximate_scrblt_order(&orderInfo, scrblt);
|
||||
update_check_flush(context, headerLength + inf);
|
||||
s = update->us;
|
||||
wStream* s = update->us;
|
||||
|
||||
if (!s)
|
||||
return TRUE;
|
||||
|
||||
offset = Stream_GetPosition(s);
|
||||
const size_t offset = Stream_GetPosition(s);
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
||||
return FALSE;
|
||||
@ -1664,25 +1654,20 @@ static BOOL update_send_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER
|
||||
|
||||
static BOOL update_send_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
|
||||
{
|
||||
wStream* s = NULL;
|
||||
int offset = 0;
|
||||
int headerLength = 0;
|
||||
ORDER_INFO orderInfo;
|
||||
int inf = 0;
|
||||
rdp_update_internal* update = NULL;
|
||||
ORDER_INFO orderInfo = { 0 };
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(line_to);
|
||||
update = update_cast(context->update);
|
||||
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_LINE_TO);
|
||||
inf = update_approximate_line_to_order(&orderInfo, line_to);
|
||||
rdp_update_internal* update = update_cast(context->update);
|
||||
const int headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_LINE_TO);
|
||||
const size_t inf = update_approximate_line_to_order(&orderInfo, line_to);
|
||||
update_check_flush(context, headerLength + inf);
|
||||
s = update->us;
|
||||
wStream* s = update->us;
|
||||
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
offset = Stream_GetPosition(s);
|
||||
const size_t offset = Stream_GetPosition(s);
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
||||
return FALSE;
|
||||
@ -1726,26 +1711,21 @@ static BOOL update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
|
||||
|
||||
static BOOL update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index)
|
||||
{
|
||||
wStream* s = NULL;
|
||||
size_t offset = 0;
|
||||
int headerLength = 0;
|
||||
int inf = 0;
|
||||
ORDER_INFO orderInfo;
|
||||
rdp_update_internal* update = NULL;
|
||||
ORDER_INFO orderInfo = { 0 };
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(glyph_index);
|
||||
update = update_cast(context->update);
|
||||
rdp_update_internal* update = update_cast(context->update);
|
||||
|
||||
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_GLYPH_INDEX);
|
||||
inf = update_approximate_glyph_index_order(&orderInfo, glyph_index);
|
||||
const int headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_GLYPH_INDEX);
|
||||
const size_t inf = update_approximate_glyph_index_order(&orderInfo, glyph_index);
|
||||
update_check_flush(context, headerLength + inf);
|
||||
s = update->us;
|
||||
wStream* s = update->us;
|
||||
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
offset = Stream_GetPosition(s);
|
||||
const size_t offset = Stream_GetPosition(s);
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, headerLength))
|
||||
return FALSE;
|
||||
@ -3309,9 +3289,7 @@ void update_free(rdpUpdate* update)
|
||||
free(altsec);
|
||||
|
||||
if (update->window)
|
||||
{
|
||||
free(update->window);
|
||||
}
|
||||
|
||||
MessageQueue_Free(up->queue);
|
||||
DeleteCriticalSection(&up->mux);
|
||||
|
@ -277,10 +277,10 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, uint8_t* buffer, si
|
||||
{
|
||||
long val = strtol(p, NULL, 0);
|
||||
|
||||
if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
|
||||
if ((errno != 0) || (val == 0) || (val > UINT32_MAX))
|
||||
return -1;
|
||||
|
||||
font->size = val;
|
||||
font->size = (UINT32)val;
|
||||
}
|
||||
*q = '"';
|
||||
|
||||
|
@ -198,7 +198,7 @@ static UINT32 drdynvc_read_variable_uint(wStream* s, UINT8 cbLen)
|
||||
return val;
|
||||
}
|
||||
|
||||
static BOOL drdynvc_try_read_header(wStream* s, size_t& channelId, size_t& length)
|
||||
static BOOL drdynvc_try_read_header(wStream* s, uint32_t& channelId, size_t& length)
|
||||
{
|
||||
UINT8 value = 0;
|
||||
Stream_SetPosition(s, 0);
|
||||
@ -350,7 +350,7 @@ static BOOL filter_dyn_channel_intercept(proxyPlugin* plugin, proxyData* pdata,
|
||||
{
|
||||
if (data->first)
|
||||
{
|
||||
size_t channelId = 0;
|
||||
uint32_t channelId = 0;
|
||||
size_t length = 0;
|
||||
if (drdynvc_try_read_header(data->data, channelId, length))
|
||||
{
|
||||
|
@ -734,11 +734,10 @@ HRESULT PathCchStripPrefixW(PWSTR pszPath, size_t cchPath)
|
||||
|
||||
if (hasPrefix)
|
||||
{
|
||||
int rc = 0;
|
||||
if (cchPath < 6)
|
||||
return S_FALSE;
|
||||
|
||||
rc = (_wcslen(&pszPath[4]) + 1);
|
||||
const size_t rc = (_wcslen(&pszPath[4]) + 1);
|
||||
if ((rc < 0) || ((INT64)cchPath < rc))
|
||||
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
|
||||
|
@ -329,7 +329,7 @@ BOOL GetSystemTimeAdjustment(PDWORD lpTimeAdjustment, PDWORD lpTimeIncrement,
|
||||
|
||||
DWORD GetTickCount(void)
|
||||
{
|
||||
return GetTickCount64();
|
||||
return (DWORD)GetTickCount64();
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
|
@ -729,7 +729,7 @@ static int dynamic_time_zone_from_localtime(const struct tm* local_time,
|
||||
{
|
||||
/* DST bias is the difference between standard time and DST in minutes */
|
||||
const LONG d = get_bias(local_time, TRUE);
|
||||
tz->DaylightBias = -1 * labs(tz->Bias - d);
|
||||
tz->DaylightBias = -1 * (LONG)labs(tz->Bias - d);
|
||||
if (!get_transition_date(local_time, FALSE, &tz->StandardDate))
|
||||
rc |= HAVE_NO_STANDARD_TRANSITION_DATE;
|
||||
if (!get_transition_date(local_time, TRUE, &tz->DaylightDate))
|
||||
|
@ -457,7 +457,7 @@ BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, size_t length, DWORD flag
|
||||
record.next = NULL;
|
||||
|
||||
UINT64 ns = winpr_GetUnixTimeNS();
|
||||
record.header.ts_sec = WINPR_TIME_NS_TO_S(ns);
|
||||
record.header.ts_sec = (UINT32)WINPR_TIME_NS_TO_S(ns);
|
||||
record.header.ts_usec = WINPR_TIME_NS_REM_US(ns);
|
||||
|
||||
if (!Pcap_Write_RecordHeader(pcap, &record.header) ||
|
||||
|
@ -761,7 +761,7 @@ int WSAEventSelect(SOCKET s, WSAEVENT hEventObject, LONG lNetworkEvents)
|
||||
if (lNetworkEvents & FD_WRITE)
|
||||
mode |= WINPR_FD_WRITE;
|
||||
|
||||
if (SetEventFileDescriptor(hEventObject, s, mode) < 0)
|
||||
if (SetEventFileDescriptor(hEventObject, (int)s, mode) < 0)
|
||||
return SOCKET_ERROR;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user