Fixed various warnings

This commit is contained in:
akallabeth 2021-11-29 14:29:07 +01:00 committed by akallabeth
parent c1f44721c5
commit 6ee60ea15a
4 changed files with 107 additions and 98 deletions

View File

@ -899,114 +899,118 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
/* tiles */
close_cnt = 0;
rc = TRUE;
rc = FALSE;
for (i = 0; i < message->numTiles; i++)
if (Stream_GetRemainingLength(s) >= tilesDataSize)
{
wStream subBuffer;
wStream* sub;
rc = TRUE;
for (i = 0; i < message->numTiles; i++)
{
wStream subBuffer;
wStream* sub;
if (!(tile = (RFX_TILE*)ObjectPool_Take(context->priv->TilePool)))
{
WLog_ERR(TAG, "RfxMessageTileSet failed to get tile from object pool");
rc = FALSE;
break;
}
message->tiles[i] = tile;
/* RFX_TILE */
if (Stream_GetRemainingLength(s) < 6)
{
WLog_ERR(TAG, "RfxMessageTileSet packet too small to read tile %d/%" PRIu16 "", i,
message->numTiles);
rc = FALSE;
break;
}
sub = Stream_StaticInit(&subBuffer, Stream_Pointer(s), Stream_GetRemainingLength(s));
Stream_Read_UINT16(sub,
blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */
Stream_Read_UINT32(sub, blockLen); /* blockLen (4 bytes) */
if (!Stream_SafeSeek(s, blockLen))
{
rc = FALSE;
break;
}
if ((blockLen < 6 + 13) || (Stream_GetRemainingLength(sub) < blockLen - 6))
{
WLog_ERR(TAG,
"RfxMessageTileSet not enough bytes to read tile %d/%" PRIu16
" with blocklen=%" PRIu32 "",
i, message->numTiles, blockLen);
rc = FALSE;
break;
}
if (blockType != CBT_TILE)
{
WLog_ERR(TAG, "unknown block type 0x%" PRIX32 ", expected CBT_TILE (0xCAC3).",
blockType);
rc = FALSE;
break;
}
Stream_Read_UINT8(sub, tile->quantIdxY); /* quantIdxY (1 byte) */
Stream_Read_UINT8(sub, tile->quantIdxCb); /* quantIdxCb (1 byte) */
Stream_Read_UINT8(sub, tile->quantIdxCr); /* quantIdxCr (1 byte) */
Stream_Read_UINT16(sub, tile->xIdx); /* xIdx (2 bytes) */
Stream_Read_UINT16(sub, tile->yIdx); /* yIdx (2 bytes) */
Stream_Read_UINT16(sub, tile->YLen); /* YLen (2 bytes) */
Stream_Read_UINT16(sub, tile->CbLen); /* CbLen (2 bytes) */
Stream_Read_UINT16(sub, tile->CrLen); /* CrLen (2 bytes) */
Stream_GetPointer(sub, tile->YData);
if (!Stream_SafeSeek(sub, tile->YLen))
{
rc = FALSE;
break;
}
Stream_GetPointer(sub, tile->CbData);
if (!Stream_SafeSeek(sub, tile->CbLen))
{
rc = FALSE;
break;
}
Stream_GetPointer(sub, tile->CrData);
if (!Stream_SafeSeek(sub, tile->CrLen))
{
rc = FALSE;
break;
}
tile->x = tile->xIdx * 64;
tile->y = tile->yIdx * 64;
if (context->priv->UseThreads)
{
if (!params)
if (!(tile = (RFX_TILE*)ObjectPool_Take(context->priv->TilePool)))
{
WLog_ERR(TAG, "RfxMessageTileSet failed to get tile from object pool");
rc = FALSE;
break;
}
params[i].context = context;
params[i].tile = message->tiles[i];
message->tiles[i] = tile;
if (!(work_objects[i] =
CreateThreadpoolWork(rfx_process_message_tile_work_callback,
(void*)&params[i], &context->priv->ThreadPoolEnv)))
/* RFX_TILE */
if (Stream_GetRemainingLength(s) < 6)
{
WLog_ERR(TAG, "CreateThreadpoolWork failed.");
WLog_ERR(TAG, "RfxMessageTileSet packet too small to read tile %d/%" PRIu16 "", i,
message->numTiles);
rc = FALSE;
break;
}
SubmitThreadpoolWork(work_objects[i]);
close_cnt = i + 1;
}
else
{
rfx_decode_rgb(context, tile, tile->data, 64 * 4);
sub = Stream_StaticInit(&subBuffer, Stream_Pointer(s), Stream_GetRemainingLength(s));
Stream_Read_UINT16(
sub, blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */
Stream_Read_UINT32(sub, blockLen); /* blockLen (4 bytes) */
if (!Stream_SafeSeek(s, blockLen))
{
rc = FALSE;
break;
}
if ((blockLen < 6 + 13) || (Stream_GetRemainingLength(sub) < blockLen - 6))
{
WLog_ERR(TAG,
"RfxMessageTileSet not enough bytes to read tile %d/%" PRIu16
" with blocklen=%" PRIu32 "",
i, message->numTiles, blockLen);
rc = FALSE;
break;
}
if (blockType != CBT_TILE)
{
WLog_ERR(TAG, "unknown block type 0x%" PRIX32 ", expected CBT_TILE (0xCAC3).",
blockType);
rc = FALSE;
break;
}
Stream_Read_UINT8(sub, tile->quantIdxY); /* quantIdxY (1 byte) */
Stream_Read_UINT8(sub, tile->quantIdxCb); /* quantIdxCb (1 byte) */
Stream_Read_UINT8(sub, tile->quantIdxCr); /* quantIdxCr (1 byte) */
Stream_Read_UINT16(sub, tile->xIdx); /* xIdx (2 bytes) */
Stream_Read_UINT16(sub, tile->yIdx); /* yIdx (2 bytes) */
Stream_Read_UINT16(sub, tile->YLen); /* YLen (2 bytes) */
Stream_Read_UINT16(sub, tile->CbLen); /* CbLen (2 bytes) */
Stream_Read_UINT16(sub, tile->CrLen); /* CrLen (2 bytes) */
Stream_GetPointer(sub, tile->YData);
if (!Stream_SafeSeek(sub, tile->YLen))
{
rc = FALSE;
break;
}
Stream_GetPointer(sub, tile->CbData);
if (!Stream_SafeSeek(sub, tile->CbLen))
{
rc = FALSE;
break;
}
Stream_GetPointer(sub, tile->CrData);
if (!Stream_SafeSeek(sub, tile->CrLen))
{
rc = FALSE;
break;
}
tile->x = tile->xIdx * 64;
tile->y = tile->yIdx * 64;
if (context->priv->UseThreads)
{
if (!params)
{
rc = FALSE;
break;
}
params[i].context = context;
params[i].tile = message->tiles[i];
if (!(work_objects[i] =
CreateThreadpoolWork(rfx_process_message_tile_work_callback,
(void*)&params[i], &context->priv->ThreadPoolEnv)))
{
WLog_ERR(TAG, "CreateThreadpoolWork failed.");
rc = FALSE;
break;
}
SubmitThreadpoolWork(work_objects[i]);
close_cnt = i + 1;
}
else
{
rfx_decode_rgb(context, tile, tile->data, 64 * 4);
}
}
}

View File

@ -1005,15 +1005,22 @@ static BOOL rdp_recv_logon_info_v2(rdpRdp* rdp, wStream* s, logon_info* info)
UINT32 Size;
UINT32 cbDomain;
UINT32 cbUserName;
const size_t logonInfoV2Size = 576;
WINPR_UNUSED(rdp);
ZeroMemory(info, sizeof(*info));
if (Stream_GetRemainingLength(s) < 576)
if (Stream_GetRemainingLength(s) < logonInfoV2Size)
return FALSE;
Stream_Read_UINT16(s, Version); /* Version (2 bytes) */
if (Version != SAVE_SESSION_PDU_VERSION_ONE)
return FALSE;
Stream_Read_UINT32(s, Size); /* Size (4 bytes) */
if (Size != 18)
return FALSE;
Stream_Read_UINT32(s, info->sessionId); /* SessionId (4 bytes) */
Stream_Read_UINT32(s, cbDomain); /* cbDomain (4 bytes) */
Stream_Read_UINT32(s, cbUserName); /* cbUserName (4 bytes) */

View File

@ -1111,7 +1111,6 @@ BOOL mcs_send_channel_join_request(rdpMcs* mcs, UINT16 channelId)
BOOL mcs_recv_channel_join_confirm(rdpMcs* mcs, wStream* s, UINT16* channelId)
{
BOOL status;
UINT16 length;
BYTE result;
UINT16 initiator;
@ -1121,7 +1120,6 @@ BOOL mcs_recv_channel_join_confirm(rdpMcs* mcs, wStream* s, UINT16* channelId)
if (!mcs || !s || !channelId)
return FALSE;
status = TRUE;
MCSPDU = DomainMCSPDU_ChannelJoinConfirm;
if (!mcs_read_domain_mcspdu_header(s, &MCSPDU, &length))
return FALSE;

View File

@ -157,5 +157,5 @@ fail:
free(keyNames);
free(sectionNames);
IniFile_Free(ini);
return 0;
return rc;
}