mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[allocations] fix growth of preallocated buffers
* Replace * 2 with * sizeof(WCHAR) for string usages * Grow streams and other buffers reasonably, e.g. add 128 elements per try and check for possible overflows * Add constant postfix to force them to 64bit
This commit is contained in:
@@ -36,7 +36,7 @@ UINT remdesk_write_channel_header(wStream* s, const REMDESK_CHANNEL_HEADER* head
|
||||
}
|
||||
|
||||
const size_t ChannelNameLen =
|
||||
(strnlen(header->ChannelName, sizeof(header->ChannelName)) + 1) * 2;
|
||||
(strnlen(header->ChannelName, sizeof(header->ChannelName)) + 1) * sizeof(WCHAR);
|
||||
WINPR_ASSERT(ChannelNameLen <= ARRAYSIZE(header->ChannelName));
|
||||
|
||||
Stream_Write_UINT32(s, (UINT32)ChannelNameLen); /* ChannelNameLen (4 bytes) */
|
||||
|
||||
@@ -185,7 +185,7 @@ static UINT remdesk_recv_ctl_remote_control_desktop_pdu(RemdeskServerContext* co
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
cchStringW++;
|
||||
const size_t cbRaConnectionStringW = cchStringW * 2;
|
||||
const size_t cbRaConnectionStringW = cchStringW * sizeof(WCHAR);
|
||||
pdu.raConnectionString =
|
||||
ConvertWCharNToUtf8Alloc(raConnectionStringW, cbRaConnectionStringW / sizeof(WCHAR), NULL);
|
||||
if (!pdu.raConnectionString)
|
||||
@@ -240,7 +240,7 @@ static UINT remdesk_recv_ctl_authenticate_pdu(WINPR_ATTR_UNUSED RemdeskServerCon
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
cchStringW++;
|
||||
const size_t cbExpertBlobW = cchStringW * 2;
|
||||
const size_t cbExpertBlobW = cchStringW * sizeof(WCHAR);
|
||||
pdu.raConnectionString =
|
||||
ConvertWCharNToUtf8Alloc(raConnectionStringW, cbRaConnectionStringW / sizeof(WCHAR), NULL);
|
||||
if (!pdu.raConnectionString)
|
||||
|
||||
Reference in New Issue
Block a user