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:
@@ -1999,7 +1999,8 @@ BOOL gcc_write_server_network_data(wStream* s, const rdpMcs* mcs)
|
||||
{
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(mcs);
|
||||
const size_t payloadLen = 8 + mcs->channelCount * 2 + (mcs->channelCount % 2 == 1 ? 2 : 0);
|
||||
const size_t payloadLen =
|
||||
8ull + mcs->channelCount * 2ull + (mcs->channelCount % 2 == 1 ? 2ull : 0ull);
|
||||
|
||||
WINPR_ASSERT(payloadLen <= UINT16_MAX);
|
||||
if (!gcc_write_user_data_header(s, SC_NET, (UINT16)payloadLen))
|
||||
|
||||
@@ -3302,7 +3302,7 @@ size_t update_approximate_create_offscreen_bitmap_order(
|
||||
deleteList = &(create_offscreen_bitmap->deleteList);
|
||||
WINPR_ASSERT(deleteList);
|
||||
|
||||
return 32 + deleteList->cIndices * 2;
|
||||
return 32ull + deleteList->cIndices * 2ull;
|
||||
}
|
||||
|
||||
BOOL update_write_create_offscreen_bitmap_order(
|
||||
|
||||
@@ -597,7 +597,7 @@ static BOOL http_proxy_connect(rdpContext* context, BIO* bufferedBio, const char
|
||||
|
||||
hostLen = strlen(hostname);
|
||||
portLen = strnlen(port_str, sizeof(port_str));
|
||||
reserveSize = strlen(connect) + (hostLen + 1 + portLen) * 2 + strlen(httpheader);
|
||||
reserveSize = strlen(connect) + (hostLen + 1ull + portLen) * 2ull + strlen(httpheader);
|
||||
s = Stream_New(NULL, reserveSize);
|
||||
if (!s)
|
||||
goto fail;
|
||||
|
||||
Reference in New Issue
Block a user