[core,fastpath] fix bulk max size
the type is UINT16 so the maximum size can only be UINT16_MAX
This commit is contained in:
parent
4560e047b5
commit
0d78b871e5
@ -37,7 +37,7 @@ struct rdp_bulk
|
|||||||
{
|
{
|
||||||
ALIGN64 rdpContext* context;
|
ALIGN64 rdpContext* context;
|
||||||
ALIGN64 UINT32 CompressionLevel;
|
ALIGN64 UINT32 CompressionLevel;
|
||||||
ALIGN64 UINT32 CompressionMaxSize;
|
ALIGN64 UINT16 CompressionMaxSize;
|
||||||
ALIGN64 MPPC_CONTEXT* mppcSend;
|
ALIGN64 MPPC_CONTEXT* mppcSend;
|
||||||
ALIGN64 MPPC_CONTEXT* mppcRecv;
|
ALIGN64 MPPC_CONTEXT* mppcRecv;
|
||||||
ALIGN64 NCRUSH_CONTEXT* ncrushRecv;
|
ALIGN64 NCRUSH_CONTEXT* ncrushRecv;
|
||||||
@ -83,14 +83,15 @@ static UINT32 bulk_compression_level(rdpBulk* WINPR_RESTRICT bulk)
|
|||||||
bulk->CompressionLevel = (settings->CompressionLevel >= PACKET_COMPR_TYPE_RDP61)
|
bulk->CompressionLevel = (settings->CompressionLevel >= PACKET_COMPR_TYPE_RDP61)
|
||||||
? PACKET_COMPR_TYPE_RDP61
|
? PACKET_COMPR_TYPE_RDP61
|
||||||
: settings->CompressionLevel;
|
: settings->CompressionLevel;
|
||||||
|
WINPR_ASSERT(bulk->CompressionLevel <= UINT16_MAX);
|
||||||
return bulk->CompressionLevel;
|
return bulk->CompressionLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 bulk_compression_max_size(rdpBulk* WINPR_RESTRICT bulk)
|
UINT16 bulk_compression_max_size(rdpBulk* WINPR_RESTRICT bulk)
|
||||||
{
|
{
|
||||||
WINPR_ASSERT(bulk);
|
WINPR_ASSERT(bulk);
|
||||||
bulk_compression_level(bulk);
|
(void)bulk_compression_level(bulk);
|
||||||
bulk->CompressionMaxSize = (bulk->CompressionLevel < PACKET_COMPR_TYPE_64K) ? 8192 : 65536;
|
bulk->CompressionMaxSize = (bulk->CompressionLevel < PACKET_COMPR_TYPE_64K) ? 8192 : UINT16_MAX;
|
||||||
return bulk->CompressionMaxSize;
|
return bulk->CompressionMaxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ int bulk_decompress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSr
|
|||||||
rdpMetrics* metrics = bulk->context->metrics;
|
rdpMetrics* metrics = bulk->context->metrics;
|
||||||
WINPR_ASSERT(metrics);
|
WINPR_ASSERT(metrics);
|
||||||
|
|
||||||
bulk_compression_max_size(bulk);
|
(void)bulk_compression_max_size(bulk);
|
||||||
const UINT32 type = flags & BULK_COMPRESSION_TYPE_MASK;
|
const UINT32 type = flags & BULK_COMPRESSION_TYPE_MASK;
|
||||||
|
|
||||||
if (flags & BULK_COMPRESSION_FLAGS_MASK)
|
if (flags & BULK_COMPRESSION_FLAGS_MASK)
|
||||||
@ -259,8 +260,8 @@ int bulk_compress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSrcD
|
|||||||
}
|
}
|
||||||
|
|
||||||
*pDstSize = sizeof(bulk->OutputBuffer);
|
*pDstSize = sizeof(bulk->OutputBuffer);
|
||||||
bulk_compression_level(bulk);
|
(void)bulk_compression_level(bulk);
|
||||||
bulk_compression_max_size(bulk);
|
(void)bulk_compression_max_size(bulk);
|
||||||
|
|
||||||
switch (bulk->CompressionLevel)
|
switch (bulk->CompressionLevel)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ typedef struct rdp_bulk rdpBulk;
|
|||||||
#define BULK_COMPRESSION_FLAGS_MASK 0xE0
|
#define BULK_COMPRESSION_FLAGS_MASK 0xE0
|
||||||
#define BULK_COMPRESSION_TYPE_MASK 0x0F
|
#define BULK_COMPRESSION_TYPE_MASK 0x0F
|
||||||
|
|
||||||
FREERDP_LOCAL UINT32 bulk_compression_max_size(rdpBulk* WINPR_RESTRICT bulk);
|
FREERDP_LOCAL UINT16 bulk_compression_max_size(rdpBulk* WINPR_RESTRICT bulk);
|
||||||
|
|
||||||
FREERDP_LOCAL int bulk_decompress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSrcData,
|
FREERDP_LOCAL int bulk_decompress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSrcData,
|
||||||
UINT32 SrcSize, const BYTE** WINPR_RESTRICT ppDstData,
|
UINT32 SrcSize, const BYTE** WINPR_RESTRICT ppDstData,
|
||||||
|
@ -1189,9 +1189,8 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
|||||||
|
|
||||||
if (settings->CompressionEnabled && !skipCompression)
|
if (settings->CompressionEnabled && !skipCompression)
|
||||||
{
|
{
|
||||||
const UINT32 CompressionMaxSize = bulk_compression_max_size(rdp->bulk);
|
const UINT16 CompressionMaxSize = bulk_compression_max_size(rdp->bulk);
|
||||||
WINPR_ASSERT(CompressionMaxSize <= UINT16_MAX);
|
maxLength = (maxLength < CompressionMaxSize) ? maxLength : CompressionMaxSize;
|
||||||
maxLength = (maxLength < CompressionMaxSize) ? maxLength : (UINT16)(CompressionMaxSize);
|
|
||||||
maxLength -= 20;
|
maxLength -= 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user