[winpr,stream] Fix Stream_SetPosition return checks

This commit is contained in:
Armin Novak
2026-02-27 20:59:11 +01:00
parent 0f46216a24
commit e6fca2c021
52 changed files with 414 additions and 233 deletions

View File

@@ -147,10 +147,10 @@ static BOOL rdp_capability_set_finish(wStream* s, size_t header, UINT16 type)
const size_t length = footer - header;
if ((Stream_Capacity(s) < header + 4ULL) || (length > UINT16_MAX))
return FALSE;
Stream_SetPosition(s, header);
if (!Stream_SetPosition(s, header))
return FALSE;
rdp_write_capability_set_header(s, (UINT16)length, type);
Stream_SetPosition(s, footer);
return TRUE;
return Stream_SetPosition(s, footer);
}
static BOOL rdp_apply_general_capability_set(rdpSettings* settings, const rdpSettings* src)
@@ -3946,7 +3946,9 @@ BOOL rdp_print_capability_sets(wLog* log, wStream* s, size_t start, BOOL receivi
size_t pos = Stream_GetPosition(s);
Stream_SetPosition(s, start);
if (!Stream_SetPosition(s, start))
goto fail;
if (receiving)
{
if (!Stream_CheckAndLogRequiredLengthWLog(log, s, 4))
@@ -4170,7 +4172,9 @@ BOOL rdp_print_capability_sets(wLog* log, wStream* s, size_t start, BOOL receivi
rc = TRUE;
fail:
Stream_SetPosition(s, pos);
if (!Stream_SetPosition(s, pos))
return FALSE;
return rc;
}
#endif
@@ -4692,18 +4696,21 @@ static BOOL rdp_write_demand_active(wLog* log, wStream* s, rdpSettings* settings
}
em = Stream_GetPosition(s);
Stream_SetPosition(s, lm); /* go back to lengthCombinedCapabilities */
if (!Stream_SetPosition(s, lm)) /* go back to lengthCombinedCapabilities */
return FALSE;
lengthCombinedCapabilities = (em - bm);
if (lengthCombinedCapabilities > UINT16_MAX)
return FALSE;
Stream_Write_UINT16(
s, (UINT16)lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */
Stream_SetPosition(s, bm); /* go back to numberCapabilities */
if (!Stream_SetPosition(s, bm)) /* go back to numberCapabilities */
return FALSE;
Stream_Write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */
#ifdef WITH_DEBUG_CAPABILITIES
rdp_print_capability_sets(log, s, bm, FALSE);
#endif
Stream_SetPosition(s, em);
if (!Stream_SetPosition(s, em))
return FALSE;
Stream_Write_UINT32(s, 0); /* sessionId */
return TRUE;
}
@@ -4931,20 +4938,20 @@ static BOOL rdp_write_confirm_active(wLog* log, wStream* s, rdpSettings* setting
}
em = Stream_GetPosition(s);
Stream_SetPosition(s, lm); /* go back to lengthCombinedCapabilities */
if (!Stream_SetPosition(s, lm)) /* go back to lengthCombinedCapabilities */
return FALSE;
lengthCombinedCapabilities = (em - bm);
if (lengthCombinedCapabilities > UINT16_MAX)
return FALSE;
Stream_Write_UINT16(
s, (UINT16)lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */
Stream_SetPosition(s, bm); /* go back to numberCapabilities */
if (!Stream_SetPosition(s, bm)) /* go back to numberCapabilities */
return FALSE;
Stream_Write_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */
#ifdef WITH_DEBUG_CAPABILITIES
rdp_print_capability_sets(log, s, bm, FALSE);
#endif
Stream_SetPosition(s, em);
return TRUE;
return Stream_SetPosition(s, em);
}
BOOL rdp_send_confirm_active(rdpRdp* rdp)

View File

@@ -1191,14 +1191,17 @@ state_run_t rdp_handle_message_channel(rdpRdp* rdp, wStream* s, UINT16 channelId
BOOL rdp_client_connect_auto_detect(rdpRdp* rdp, wStream* s, DWORD logLevel)
{
BOOL res = TRUE;
WINPR_ASSERT(rdp);
WINPR_ASSERT(rdp->mcs);
const size_t pos = Stream_GetPosition(s);
size_t pos = Stream_GetPosition(s);
UINT16 length = 0;
UINT16 channelId = 0;
if (rdp_read_header(rdp, s, &length, &channelId))
if (!rdp_read_header(rdp, s, &length, &channelId))
res = FALSE;
else
{
const UINT16 messageChannelId = rdp->mcs->messageChannelId;
/* If the MCS message channel has been joined... */
@@ -1207,18 +1210,21 @@ BOOL rdp_client_connect_auto_detect(rdpRdp* rdp, wStream* s, DWORD logLevel)
if (rdp->mcs->messageChannelJoined && (channelId == messageChannelId))
{
const state_run_t rc = rdp_handle_message_channel(rdp, s, channelId, length);
return state_run_success(rc);
res = state_run_success(rc);
pos = Stream_GetPosition(s);
}
else
{
wLog* log = WLog_Get(TAG);
WLog_Print(log, logLevel, "expected messageChannelId=%" PRIu16 ", got %" PRIu16,
messageChannelId, channelId);
res = FALSE;
}
}
Stream_SetPosition(s, pos);
return FALSE;
if (!Stream_SetPosition(s, pos))
res = FALSE;
return res;
}
state_run_t rdp_client_connect_license(rdpRdp* rdp, wStream* s)

View File

@@ -1131,9 +1131,11 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, size_t
* the data first and then store the header.
*/
WINPR_ASSERT(length < UINT16_MAX);
Stream_SetPosition(s, 1);
if (!Stream_SetPosition(s, 1))
goto fail;
Stream_Write_UINT16_BE(s, 0x8000 | (UINT16)length);
Stream_SetPosition(s, length);
if (!Stream_SetPosition(s, length))
goto fail;
Stream_SealLength(s);
}

View File

@@ -346,9 +346,11 @@ BOOL rpc_recv_bind_ack_pdu(rdpRpc* rpc, wStream* s)
/* Get the correct offset in the input data and pass that on as input buffer.
* rts_read_pdu_header did already do consistency checks */
end = Stream_GetPosition(s);
Stream_SetPosition(s, pos + header.common.frag_length - header.common.auth_length);
if (!Stream_SetPosition(s, pos + header.common.frag_length - header.common.auth_length))
goto fail;
auth_data = Stream_ConstPointer(s);
Stream_SetPosition(s, end);
if (!Stream_SetPosition(s, end))
goto fail;
buffer.cbBuffer = header.common.auth_length;
buffer.pvBuffer = malloc(buffer.cbBuffer);

View File

@@ -424,7 +424,8 @@ static int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment)
if (Stream_Length(fragment) < StubOffset + 4)
goto fail;
Stream_SetPosition(fragment, StubOffset);
if (!Stream_SetPosition(fragment, StubOffset))
goto fail;
Stream_Read_UINT32(fragment, rpc->result);
utils_abort_connect(context->rdp);
@@ -470,7 +471,8 @@ static int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment)
if (Stream_Length(fragment) < StubOffset + StubLength)
goto fail;
Stream_SetPosition(fragment, StubOffset);
if (!Stream_SetPosition(fragment, StubOffset))
goto fail;
Stream_Write(pdu->s, Stream_ConstPointer(fragment), StubLength);
rpc->StubFragCount++;
@@ -493,7 +495,8 @@ static int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment)
const rpcconn_response_hdr_t* response = &header.response;
if (Stream_Length(fragment) < StubOffset + StubLength)
goto fail;
Stream_SetPosition(fragment, StubOffset);
if (!Stream_SetPosition(fragment, StubOffset))
goto fail;
rpc_client_receive_pipe_write(rpc->client, Stream_ConstPointer(fragment), StubLength);
rpc->StubFragCount++;
@@ -704,7 +707,8 @@ static SSIZE_T rpc_client_default_out_channel_recv(rdpRpc* rpc)
if (rc == RTS_PDU_FAIL)
return -1;
Stream_SetPosition(fragment, pos);
if (!Stream_SetPosition(fragment, pos))
return -1;
if (header.frag_length > rpc->max_recv_frag)
{

View File

@@ -288,7 +288,8 @@ static BOOL rts_read_auth_verifier_no_checks(wStream* s, auth_verifier_co_t* aut
{
const size_t expected = header->frag_length - header->auth_length - 8;
Stream_SetPosition(s, expected);
if (!Stream_SetPosition(s, expected))
return FALSE;
if (!Stream_ConditionalCheckAndLogRequiredLength(TAG, s, 8, silent))
return FALSE;

View File

@@ -1834,14 +1834,15 @@ BOOL gcc_write_server_security_data(wStream* s, rdpMcs* mcs)
WINPR_ASSERT(end >= posHeader);
const size_t diff = end - posHeader;
WINPR_ASSERT(diff <= UINT16_MAX);
Stream_SetPosition(s, posHeader);
if (!Stream_SetPosition(s, posHeader))
return FALSE;
if (!gcc_write_user_data_header(s, SC_SECURITY, (UINT16)diff))
return FALSE;
Stream_SetPosition(s, posCertLen);
if (!Stream_SetPosition(s, posCertLen))
return FALSE;
WINPR_ASSERT(len <= UINT32_MAX);
Stream_Write_UINT32(s, (UINT32)len);
Stream_SetPosition(s, end);
return TRUE;
return Stream_SetPosition(s, end);
}
/**

View File

@@ -782,7 +782,8 @@ static BOOL license_send(rdpLicense* license, wStream* s, BYTE type, UINT16 sec_
WINPR_ASSERT(length <= UINT16_MAX + license->PacketHeaderLength);
const UINT16 wMsgSize = (UINT16)(length - license->PacketHeaderLength);
Stream_SetPosition(s, license->PacketHeaderLength);
if (!Stream_SetPosition(s, license->PacketHeaderLength))
return FALSE;
BYTE flags = PREAMBLE_VERSION_3_0;
/**
@@ -805,7 +806,8 @@ static BOOL license_send(rdpLicense* license, wStream* s, BYTE type, UINT16 sec_
winpr_HexLogDump(license->log, WLOG_DEBUG, Stream_PointerAs(s, char) - LICENSE_PREAMBLE_LENGTH,
wMsgSize);
#endif
Stream_SetPosition(s, length);
if (!Stream_SetPosition(s, length))
return FALSE;
const BOOL ret = rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID, sec_flags);
return ret;
}

View File

@@ -890,12 +890,14 @@ static BOOL mcs_send_connect_initial(rdpMcs* mcs)
length = (em - bm);
if (length > UINT16_MAX)
goto out;
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
goto out;
if (!tpkt_write_header(s, (UINT16)length))
goto out;
if (!tpdu_write_data(s))
goto out;
Stream_SetPosition(s, em);
if (!Stream_SetPosition(s, em))
goto out;
Stream_SealLength(s);
{
@@ -1009,12 +1011,14 @@ BOOL mcs_send_connect_response(rdpMcs* mcs)
length = (em - bm);
if (length > UINT16_MAX)
goto out;
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
goto out;
if (!tpkt_write_header(s, (UINT16)length))
goto out;
if (!tpdu_write_data(s))
goto out;
Stream_SetPosition(s, em);
if (!Stream_SetPosition(s, em))
goto out;
Stream_SealLength(s);
{

View File

@@ -956,7 +956,8 @@ static BOOL nego_read_request_token_or_cookie(rdpNego* nego, wStream* s)
if (!result)
{
Stream_SetPosition(s, pos);
if (!Stream_SetPosition(s, pos))
return FALSE;
WLog_Print(nego->log, WLOG_ERROR, "invalid %s received",
isToken ? "routing token" : "cookie");
}
@@ -1154,12 +1155,14 @@ BOOL nego_send_negotiation_request(rdpNego* nego)
goto fail;
em = Stream_GetPosition(s);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
goto fail;
if (!tpkt_write_header(s, (UINT16)length))
goto fail;
if (!tpdu_write_connection_request(s, (UINT16)length - 5))
goto fail;
Stream_SetPosition(s, em);
if (!Stream_SetPosition(s, em))
goto fail;
Stream_SealLength(s);
rc = (transport_write(nego->transport, s) >= 0);
fail:
@@ -1489,11 +1492,7 @@ BOOL nego_process_negotiation_failure(rdpNego* nego, wStream* s)
BOOL nego_send_negotiation_response(rdpNego* nego)
{
UINT16 length = 0;
size_t bm = 0;
size_t em = 0;
BOOL status = 0;
wStream* s = nullptr;
BOOL status = FALSE;
BYTE flags = 0;
rdpContext* context = nullptr;
rdpSettings* settings = nullptr;
@@ -1505,7 +1504,7 @@ BOOL nego_send_negotiation_response(rdpNego* nego)
settings = context->settings;
WINPR_ASSERT(settings);
s = Stream_New(nullptr, 512);
wStream* s = Stream_New(nullptr, 512);
if (!s)
{
@@ -1513,9 +1512,10 @@ BOOL nego_send_negotiation_response(rdpNego* nego)
return FALSE;
}
length = TPDU_CONNECTION_CONFIRM_LENGTH;
bm = Stream_GetPosition(s);
Stream_Seek(s, length);
UINT16 length = TPDU_CONNECTION_CONFIRM_LENGTH;
const size_t bm = Stream_GetPosition(s);
if (!Stream_SafeSeek(s, length))
goto fail;
if (nego->SelectedProtocol & PROTOCOL_FAILED_NEGO)
{
@@ -1548,19 +1548,22 @@ BOOL nego_send_negotiation_response(rdpNego* nego)
length += 8;
}
em = Stream_GetPosition(s);
Stream_SetPosition(s, bm);
status = tpkt_write_header(s, length);
if (status)
status = tpdu_write_connection_confirm(s, length - 5);
const size_t em = Stream_GetPosition(s);
if (!Stream_SetPosition(s, bm))
goto fail;
if (!tpkt_write_header(s, length))
goto fail;
if (status)
{
Stream_SetPosition(s, em);
Stream_SealLength(s);
if (!tpdu_write_connection_confirm(s, length - 5))
goto fail;
status = (transport_write(nego->transport, s) >= 0);
}
if (!Stream_SetPosition(s, em))
goto fail;
Stream_SealLength(s);
status = (transport_write(nego->transport, s) >= 0);
fail:
Stream_Free(s, TRUE);
if (status)

View File

@@ -1267,7 +1267,8 @@ static MSV1_0_REMOTE_SUPPLEMENTAL_CREDENTIAL* nla_read_NtlmCreds(WINPR_ATTR_UNUS
if (!Stream_CheckAndLogRequiredLength(TAG, s, EncryptedCredsSize))
return nullptr;
Stream_SetPosition(s, pos);
if (!Stream_SetPosition(s, pos))
return nullptr;
MSV1_0_REMOTE_SUPPLEMENTAL_CREDENTIAL* ret = (MSV1_0_REMOTE_SUPPLEMENTAL_CREDENTIAL*)calloc(
1, sizeof(MSV1_0_REMOTE_SUPPLEMENTAL_CREDENTIAL) - 1 + EncryptedCredsSize);

View File

@@ -1189,7 +1189,10 @@ static state_run_t peer_recv_callback(rdpTransport* transport, wStream* s, void*
const char* old = rdp_get_state_string(rdp);
if (rc == STATE_RUN_TRY_AGAIN)
Stream_SetPosition(s, start);
{
if (!Stream_SetPosition(s, start))
return STATE_RUN_FAILED;
}
rc = peer_recv_callback_internal(transport, s, extra);
const size_t len = Stream_GetRemainingLength(s);

View File

@@ -849,7 +849,8 @@ BOOL rdp_send(rdpRdp* rdp, wStream* s, UINT16 channelId, UINT16 sec_flags)
goto fail;
length += pad;
Stream_SetPosition(s, length);
if (!Stream_SetPosition(s, length))
goto fail;
Stream_SealLength(s);
}
@@ -894,13 +895,15 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id, UINT1
Stream_Seek(s, sec_bytes);
if (!rdp_write_share_control_header(rdp, s, length - sec_bytes, type, channel_id))
goto fail;
Stream_SetPosition(s, sec_hold);
if (!Stream_SetPosition(s, sec_hold))
goto fail;
if (!rdp_security_stream_out(rdp, s, length, sec_flags, &pad))
goto fail;
length += pad;
Stream_SetPosition(s, length);
if (!Stream_SetPosition(s, length))
goto fail;
Stream_SealLength(s);
}
@@ -946,13 +949,15 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id, UI
goto fail;
if (!rdp_write_share_data_header(rdp, s, length - sec_bytes, type, rdp->settings->ShareId))
goto fail;
Stream_SetPosition(s, sec_hold);
if (!Stream_SetPosition(s, sec_hold))
goto fail;
if (!rdp_security_stream_out(rdp, s, length, sec_flags, &pad))
goto fail;
length += pad;
Stream_SetPosition(s, length);
if (!Stream_SetPosition(s, length))
goto fail;
Stream_SealLength(s);
}
WLog_Print(rdp->log, WLOG_DEBUG,
@@ -996,7 +1001,8 @@ BOOL rdp_send_message_channel_pdu(rdpRdp* rdp, wStream* s, UINT16 sec_flags)
goto fail;
length += pad;
Stream_SetPosition(s, length);
if (!Stream_SetPosition(s, length))
goto fail;
}
Stream_SealLength(s);
@@ -2203,7 +2209,10 @@ state_run_t rdp_recv_callback(rdpTransport* transport, wStream* s, void* extra)
WINPR_ASSERT(rdp);
if (rc == STATE_RUN_TRY_AGAIN)
Stream_SetPosition(s, start);
{
if (!Stream_SetPosition(s, start))
return STATE_RUN_FAILED;
}
const char* old = rdp_get_state_string(rdp);
const size_t orem = Stream_GetRemainingLength(s);

View File

@@ -1081,9 +1081,11 @@ BOOL rdp_write_enhanced_security_redirection_packet(wStream* s, const rdpRedirec
/* Write length field */
const size_t lend = Stream_GetPosition(s);
Stream_SetPosition(s, lstart);
if (!Stream_SetPosition(s, lstart))
goto fail;
Stream_Write_UINT32(s, length);
Stream_SetPosition(s, lend);
if (!Stream_SetPosition(s, lend))
goto fail;
}
/* Padding 8 bytes */
@@ -1093,9 +1095,11 @@ BOOL rdp_write_enhanced_security_redirection_packet(wStream* s, const rdpRedirec
{
const size_t end = Stream_GetPosition(s);
Stream_SetPosition(s, lengthOffset);
if (!Stream_SetPosition(s, lengthOffset))
goto fail;
Stream_Write_UINT16(s, (UINT16)(end - start));
Stream_SetPosition(s, end);
if (!Stream_SetPosition(s, end))
goto fail;
}
}

View File

@@ -362,7 +362,8 @@ static int stream_dump_replay_transport_read(rdpTransport* transport, wStream* s
const size_t start = Stream_GetPosition(s);
do
{
Stream_SetPosition(s, start);
if (!Stream_SetPosition(s, start))
return -1;
if (stream_dump_get(ctx, &flags, s, &ctx->dump->replayOffset, &ts) < 0)
return -1;
} while (flags & STREAM_MSG_SRV_RX);

View File

@@ -1058,9 +1058,11 @@ static BOOL s_update_end_paint(rdpContext* context)
update->us = nullptr;
Stream_SealLength(s);
Stream_SetPosition(s, update->offsetOrders);
if (!Stream_SetPosition(s, update->offsetOrders))
goto fail;
Stream_Write_UINT16(s, update->numberOrders); /* numberOrders (2 bytes) */
Stream_SetPosition(s, Stream_Length(s));
if (!Stream_SetPosition(s, Stream_Length(s)))
goto fail;
if (update->numberOrders > 0)
{
@@ -1245,7 +1247,9 @@ static int update_write_order_info(rdpContext* context, wStream* s, const ORDER_
const size_t position = Stream_GetPosition(s);
const UINT8 controlFlags = (UINT8)orderInfo->controlFlags;
Stream_SetPosition(s, offset);
if (!Stream_SetPosition(s, offset))
return -1;
Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */
if (orderInfo->controlFlags & ORDER_TYPE_CHANGE)
@@ -1258,7 +1262,8 @@ static int update_write_order_info(rdpContext* context, wStream* s, const ORDER_
return -1;
if (!update_write_bounds(s, orderInfo))
return -1;
Stream_SetPosition(s, position);
if (!Stream_SetPosition(s, position))
return -1;
return 0;
}
@@ -1854,14 +1859,14 @@ static BOOL update_send_cache_bitmap(rdpContext* context, const CACHE_BITMAP_ORD
const size_t orderLength = (em - bm) - 13;
WINPR_ASSERT(orderLength <= UINT16_MAX);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
return FALSE;
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */
Stream_SetPosition(s, em);
update->numberOrders++;
return TRUE;
return Stream_SetPosition(s, em);
}
static BOOL update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2)
@@ -1905,14 +1910,14 @@ static BOOL update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD
const size_t orderLength = (em - bm) - 13;
WINPR_ASSERT(orderLength <= UINT16_MAX);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
return FALSE;
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */
Stream_SetPosition(s, em);
update->numberOrders++;
return TRUE;
return Stream_SetPosition(s, em);
}
static BOOL update_send_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3)
@@ -1949,14 +1954,14 @@ static BOOL update_send_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORD
const size_t orderLength = (em - bm) - 13;
WINPR_ASSERT(orderLength <= UINT16_MAX);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
return FALSE;
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, extraFlags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, orderType); /* orderType (1 byte) */
Stream_SetPosition(s, em);
update->numberOrders++;
return TRUE;
return Stream_SetPosition(s, em);
}
static BOOL update_send_cache_color_table(rdpContext* context,
@@ -1992,14 +1997,14 @@ static BOOL update_send_cache_color_table(rdpContext* context,
WINPR_ASSERT(em >= bm + 13);
const size_t orderLength = (em - bm) - 13;
WINPR_ASSERT(orderLength <= UINT16_MAX);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
return FALSE;
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_COLOR_TABLE); /* orderType (1 byte) */
Stream_SetPosition(s, em);
update->numberOrders++;
return TRUE;
return Stream_SetPosition(s, em);
}
static BOOL update_send_cache_glyph(rdpContext* context, const CACHE_GLYPH_ORDER* cache_glyph)
@@ -2034,14 +2039,14 @@ static BOOL update_send_cache_glyph(rdpContext* context, const CACHE_GLYPH_ORDER
WINPR_ASSERT(em >= bm + 13);
const size_t orderLength = (em - bm) - 13;
WINPR_ASSERT(orderLength <= UINT16_MAX);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
return FALSE;
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */
Stream_SetPosition(s, em);
update->numberOrders++;
return TRUE;
return Stream_SetPosition(s, em);
}
static BOOL update_send_cache_glyph_v2(rdpContext* context,
@@ -2077,14 +2082,14 @@ static BOOL update_send_cache_glyph_v2(rdpContext* context,
WINPR_ASSERT(em >= bm + 13);
const size_t orderLength = (em - bm) - 13;
WINPR_ASSERT(orderLength <= UINT16_MAX);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
return FALSE;
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */
Stream_SetPosition(s, em);
update->numberOrders++;
return TRUE;
return Stream_SetPosition(s, em);
}
static BOOL update_send_cache_brush(rdpContext* context, const CACHE_BRUSH_ORDER* cache_brush)
@@ -2121,14 +2126,14 @@ static BOOL update_send_cache_brush(rdpContext* context, const CACHE_BRUSH_ORDER
const size_t orderLength = (em - bm) - 13;
WINPR_ASSERT(orderLength <= UINT16_MAX);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
return FALSE;
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, (UINT16)orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_BRUSH); /* orderType (1 byte) */
Stream_SetPosition(s, em);
update->numberOrders++;
return TRUE;
return Stream_SetPosition(s, em);
}
/**
@@ -2165,12 +2170,12 @@ static BOOL update_send_create_offscreen_bitmap_order(
return FALSE;
const size_t em = Stream_GetPosition(s);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
return FALSE;
Stream_Write_UINT8(s,
WINPR_ASSERTING_INT_CAST(uint8_t, controlFlags)); /* controlFlags (1 byte) */
Stream_SetPosition(s, em);
update->numberOrders++;
return TRUE;
return Stream_SetPosition(s, em);
}
static BOOL update_send_switch_surface_order(rdpContext* context,
@@ -2203,12 +2208,12 @@ static BOOL update_send_switch_surface_order(rdpContext* context,
return FALSE;
const size_t em = Stream_GetPosition(s);
Stream_SetPosition(s, bm);
if (!Stream_SetPosition(s, bm))
return FALSE;
Stream_Write_UINT8(s,
WINPR_ASSERTING_INT_CAST(uint8_t, controlFlags)); /* controlFlags (1 byte) */
Stream_SetPosition(s, em);
update->numberOrders++;
return TRUE;
return Stream_SetPosition(s, em);
}
static BOOL update_send_pointer_system(rdpContext* context,