Merge pull request #10768 from akallabeth/stream-write-assert

[winpr,stream] assert Stream_Write_(U)INT[8|16|32] ranges
This commit is contained in:
akallabeth 2024-10-26 14:40:43 +02:00 committed by GitHub
commit d19b7fa5d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 441 additions and 192 deletions

View File

@ -151,7 +151,11 @@ BOOL multitransport_client_send_response(rdpMultitransport* multi, UINT32 reqId,
}
Stream_Write_UINT32(s, reqId); /* requestId (4 bytes) */
Stream_Write_UINT32(s, hr); /* HResult (4 bytes) */
/* [MS-RDPBCGR] 2.2.15.2 Client Initiate Multitransport Response PDU defines this as 4byte
* UNSIGNED but https://learn.microsoft.com/en-us/windows/win32/learnwin32/error-codes-in-com
* defines this as signed... assume the spec is (implicitly) assuming twos complement. */
Stream_Write_INT32(s, hr); /* HResult (4 bytes) */
return rdp_send_message_channel_pdu(multi->rdp, s, SEC_TRANSPORT_RSP);
}

View File

@ -537,8 +537,25 @@ static INLINE BOOL update_read_coord(wStream* s, INT32* coord, BOOL delta)
return TRUE;
}
static INLINE BOOL update_write_coord(wStream* s, INT32 coord)
#define update_write_coord(s, coord) \
update_write_coord_int((s), (coord), #coord, __FILE__, __func__, __LINE__)
static INLINE BOOL update_write_coord_int(wStream* s, INT32 coord, const char* name,
const char* file, const char* fkt, size_t line)
{
if ((coord < 0) || (coord > UINT16_MAX))
{
const DWORD level = WLOG_WARN;
wLog* log = WLog_Get(TAG);
if (WLog_IsLevelActive(log, level))
{
WLog_PrintMessage(log, WLOG_MESSAGE_TEXT, level, line, file, fkt,
"[%s] 0 <= %" PRId32 " <= %" PRIu16, name, coord, UINT16_MAX);
}
return FALSE;
}
Stream_Write_UINT16(s, coord);
return TRUE;
}
@ -1255,13 +1272,17 @@ BOOL update_write_dstblt_order(wStream* s, ORDER_INFO* orderInfo, const DSTBLT_O
orderInfo->fieldFlags = 0;
orderInfo->fieldFlags |= ORDER_FIELD_01;
update_write_coord(s, dstblt->nLeftRect);
if (!update_write_coord(s, dstblt->nLeftRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_02;
update_write_coord(s, dstblt->nTopRect);
if (!update_write_coord(s, dstblt->nTopRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_03;
update_write_coord(s, dstblt->nWidth);
if (!update_write_coord(s, dstblt->nWidth))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_04;
update_write_coord(s, dstblt->nHeight);
if (!update_write_coord(s, dstblt->nHeight))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_05;
Stream_Write_UINT8(s, dstblt->bRop);
return TRUE;
@ -1296,13 +1317,17 @@ BOOL update_write_patblt_order(wStream* s, ORDER_INFO* orderInfo, PATBLT_ORDER*
orderInfo->fieldFlags = 0;
orderInfo->fieldFlags |= ORDER_FIELD_01;
update_write_coord(s, patblt->nLeftRect);
if (!update_write_coord(s, patblt->nLeftRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_02;
update_write_coord(s, patblt->nTopRect);
if (!update_write_coord(s, patblt->nTopRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_03;
update_write_coord(s, patblt->nWidth);
if (!update_write_coord(s, patblt->nWidth))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_04;
update_write_coord(s, patblt->nHeight);
if (!update_write_coord(s, patblt->nHeight))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_05;
Stream_Write_UINT8(s, patblt->bRop);
orderInfo->fieldFlags |= ORDER_FIELD_06;
@ -1346,19 +1371,25 @@ BOOL update_write_scrblt_order(wStream* s, ORDER_INFO* orderInfo, const SCRBLT_O
orderInfo->fieldFlags = 0;
orderInfo->fieldFlags |= ORDER_FIELD_01;
update_write_coord(s, scrblt->nLeftRect);
if (!update_write_coord(s, scrblt->nLeftRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_02;
update_write_coord(s, scrblt->nTopRect);
if (!update_write_coord(s, scrblt->nTopRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_03;
update_write_coord(s, scrblt->nWidth);
if (!update_write_coord(s, scrblt->nWidth))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_04;
update_write_coord(s, scrblt->nHeight);
if (!update_write_coord(s, scrblt->nHeight))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_05;
Stream_Write_UINT8(s, scrblt->bRop);
orderInfo->fieldFlags |= ORDER_FIELD_06;
update_write_coord(s, scrblt->nXSrc);
if (!update_write_coord(s, scrblt->nXSrc))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_07;
update_write_coord(s, scrblt->nYSrc);
if (!update_write_coord(s, scrblt->nYSrc))
return FALSE;
return TRUE;
}
static BOOL update_read_opaque_rect_order(const char* orderName, wStream* s,
@ -1422,13 +1453,17 @@ BOOL update_write_opaque_rect_order(wStream* s, ORDER_INFO* orderInfo,
// TODO: Color format conversion
orderInfo->fieldFlags = 0;
orderInfo->fieldFlags |= ORDER_FIELD_01;
update_write_coord(s, opaque_rect->nLeftRect);
if (!update_write_coord(s, opaque_rect->nLeftRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_02;
update_write_coord(s, opaque_rect->nTopRect);
if (!update_write_coord(s, opaque_rect->nTopRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_03;
update_write_coord(s, opaque_rect->nWidth);
if (!update_write_coord(s, opaque_rect->nWidth))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_04;
update_write_coord(s, opaque_rect->nHeight);
if (!update_write_coord(s, opaque_rect->nHeight))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_05;
byte = opaque_rect->color & 0x000000FF;
Stream_Write_UINT8(s, byte);
@ -1702,13 +1737,17 @@ BOOL update_write_line_to_order(wStream* s, ORDER_INFO* orderInfo, const LINE_TO
orderInfo->fieldFlags |= ORDER_FIELD_01;
Stream_Write_UINT16(s, line_to->backMode);
orderInfo->fieldFlags |= ORDER_FIELD_02;
update_write_coord(s, line_to->nXStart);
if (!update_write_coord(s, line_to->nXStart))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_03;
update_write_coord(s, line_to->nYStart);
if (!update_write_coord(s, line_to->nYStart))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_04;
update_write_coord(s, line_to->nXEnd);
if (!update_write_coord(s, line_to->nXEnd))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_05;
update_write_coord(s, line_to->nYEnd);
if (!update_write_coord(s, line_to->nYEnd))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_06;
update_write_color(s, line_to->backColor);
orderInfo->fieldFlags |= ORDER_FIELD_07;
@ -1800,19 +1839,25 @@ BOOL update_write_memblt_order(wStream* s, ORDER_INFO* orderInfo, const MEMBLT_O
orderInfo->fieldFlags |= ORDER_FIELD_01;
Stream_Write_UINT16(s, cacheId);
orderInfo->fieldFlags |= ORDER_FIELD_02;
update_write_coord(s, memblt->nLeftRect);
if (!update_write_coord(s, memblt->nLeftRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_03;
update_write_coord(s, memblt->nTopRect);
if (!update_write_coord(s, memblt->nTopRect))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_04;
update_write_coord(s, memblt->nWidth);
if (!update_write_coord(s, memblt->nWidth))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_05;
update_write_coord(s, memblt->nHeight);
if (!update_write_coord(s, memblt->nHeight))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_06;
Stream_Write_UINT8(s, memblt->bRop);
orderInfo->fieldFlags |= ORDER_FIELD_07;
update_write_coord(s, memblt->nXSrc);
if (!update_write_coord(s, memblt->nXSrc))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_08;
update_write_coord(s, memblt->nYSrc);
if (!update_write_coord(s, memblt->nYSrc))
return FALSE;
orderInfo->fieldFlags |= ORDER_FIELD_09;
Stream_Write_UINT16(s, memblt->cacheIndex);
return TRUE;

View File

@ -226,10 +226,8 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings)
BOOL rdp_write_client_time_zone(wStream* s, rdpSettings* settings)
{
LPTIME_ZONE_INFORMATION tz = { 0 };
WINPR_ASSERT(settings);
tz = settings->ClientTimeZone;
const LPTIME_ZONE_INFORMATION tz = settings->ClientTimeZone;
if (!tz)
return FALSE;
@ -238,8 +236,12 @@ BOOL rdp_write_client_time_zone(wStream* s, rdpSettings* settings)
if (!Stream_EnsureRemainingCapacity(s, 4ull + sizeof(tz->StandardName)))
return FALSE;
/* Bias */
Stream_Write_UINT32(s, tz->Bias);
/* Bias defined in windows headers as LONG
* but [MS-RDPBCGR] 2.2.1.11.1.1.1.1 Time Zone Information (TS_TIME_ZONE_INFORMATION) defines it
* as unsigned.... assume the spec is buggy as an unsigned value only works on half of the
* world.
*/
Stream_Write_INT32(s, tz->Bias);
/* standardName (64 bytes) */
Stream_Write(s, tz->StandardName, sizeof(tz->StandardName));
/* StandardDate */
@ -250,7 +252,13 @@ BOOL rdp_write_client_time_zone(wStream* s, rdpSettings* settings)
/* StandardBias */
if (!Stream_EnsureRemainingCapacity(s, 4ull + sizeof(tz->DaylightName)))
return FALSE;
Stream_Write_UINT32(s, tz->StandardBias);
/* StandardBias defined in windows headers as LONG
* but [MS-RDPBCGR] 2.2.1.11.1.1.1.1 Time Zone Information (TS_TIME_ZONE_INFORMATION) defines it
* as unsigned.... assume the spec is buggy as an unsigned value only works on half of the
* world.
*/
Stream_Write_INT32(s, tz->StandardBias);
/* daylightName (64 bytes) */
Stream_Write(s, tz->DaylightName, sizeof(tz->DaylightName));
@ -261,7 +269,13 @@ BOOL rdp_write_client_time_zone(wStream* s, rdpSettings* settings)
/* DaylightBias */
if (!Stream_EnsureRemainingCapacity(s, 4ull))
return FALSE;
Stream_Write_UINT32(s, tz->DaylightBias);
/* DaylightBias defined in windows headers as LONG
* but [MS-RDPBCGR] 2.2.1.11.1.1.1.1 Time Zone Information (TS_TIME_ZONE_INFORMATION) defines it
* as unsigned.... assume the spec is buggy as an unsigned value only works on half of the
* world.
*/
Stream_Write_INT32(s, tz->DaylightBias);
return TRUE;
}

View File

@ -1062,13 +1062,10 @@ static void update_force_flush(rdpContext* context)
static BOOL update_check_flush(rdpContext* context, size_t size)
{
wStream* s = NULL;
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
s = update->us;
wStream* s = update->us;
if (!update->us)
{
@ -1182,10 +1179,9 @@ static int update_prepare_bounds(rdpContext* context, ORDER_INFO* orderInfo)
return length;
}
static int update_prepare_order_info(rdpContext* context, ORDER_INFO* orderInfo, UINT32 orderType)
static size_t update_prepare_order_info(rdpContext* context, ORDER_INFO* orderInfo,
UINT32 orderType)
{
int length = 1;
WINPR_ASSERT(context);
WINPR_ASSERT(orderInfo);
@ -1193,7 +1189,7 @@ static int update_prepare_order_info(rdpContext* context, ORDER_INFO* orderInfo,
orderInfo->orderType = orderType;
orderInfo->controlFlags = ORDER_STANDARD;
orderInfo->controlFlags |= ORDER_TYPE_CHANGE;
length += 1;
size_t length = 2;
length += get_primary_drawing_order_field_bytes(orderInfo->orderType, NULL);
length += update_prepare_bounds(context, orderInfo);
return length;
@ -1538,9 +1534,11 @@ static BOOL update_send_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
rdp_update_internal* update = update_cast(context->update);
const int headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_DSTBLT);
const size_t headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_DSTBLT);
const size_t inf = update_approximate_dstblt_order(&orderInfo, dstblt);
update_check_flush(context, headerLength + inf);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
@ -1563,19 +1561,19 @@ static BOOL update_send_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt)
static BOOL update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
wStream* s = NULL;
size_t offset = 0;
int headerLength = 0;
ORDER_INFO orderInfo;
rdp_update_internal* update = NULL;
ORDER_INFO orderInfo = { 0 };
WINPR_ASSERT(context);
WINPR_ASSERT(patblt);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_PATBLT);
update_check_flush(context, headerLength + update_approximate_patblt_order(&orderInfo, patblt));
s = update->us;
const size_t headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_PATBLT);
if (!update_check_flush(context,
headerLength + update_approximate_patblt_order(&orderInfo, patblt)))
return FALSE;
wStream* s = update->us;
if (!s)
return FALSE;
@ -1600,9 +1598,11 @@ static BOOL update_send_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
WINPR_ASSERT(scrblt);
rdp_update_internal* update = update_cast(context->update);
const int headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_SCRBLT);
const size_t headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_SCRBLT);
const size_t inf = update_approximate_scrblt_order(&orderInfo, scrblt);
update_check_flush(context, headerLength + inf);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
@ -1622,20 +1622,20 @@ static BOOL update_send_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt)
static BOOL update_send_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque_rect)
{
wStream* s = NULL;
size_t offset = 0;
int headerLength = 0;
ORDER_INFO orderInfo;
rdp_update_internal* update = NULL;
ORDER_INFO orderInfo = { 0 };
WINPR_ASSERT(context);
WINPR_ASSERT(opaque_rect);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_OPAQUE_RECT);
update_check_flush(context, headerLength +
update_approximate_opaque_rect_order(&orderInfo, opaque_rect));
s = update->us;
const size_t headerLength =
update_prepare_order_info(context, &orderInfo, ORDER_TYPE_OPAQUE_RECT);
if (!update_check_flush(
context, headerLength + update_approximate_opaque_rect_order(&orderInfo, opaque_rect)))
return FALSE;
wStream* s = update->us;
if (!s)
return FALSE;
@ -1659,9 +1659,11 @@ static BOOL update_send_line_to(rdpContext* context, const LINE_TO_ORDER* line_t
WINPR_ASSERT(context);
WINPR_ASSERT(line_to);
rdp_update_internal* update = update_cast(context->update);
const int headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_LINE_TO);
const size_t headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_LINE_TO);
const size_t inf = update_approximate_line_to_order(&orderInfo, line_to);
update_check_flush(context, headerLength + inf);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
@ -1681,18 +1683,18 @@ static BOOL update_send_line_to(rdpContext* context, const LINE_TO_ORDER* line_t
static BOOL update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
{
wStream* s = NULL;
size_t offset = 0;
int headerLength = 0;
ORDER_INFO orderInfo;
rdp_update_internal* update = NULL;
ORDER_INFO orderInfo = { 0 };
WINPR_ASSERT(context);
WINPR_ASSERT(memblt);
update = update_cast(context->update);
headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_MEMBLT);
update_check_flush(context, headerLength + update_approximate_memblt_order(&orderInfo, memblt));
s = update->us;
rdp_update_internal* update = update_cast(context->update);
const size_t headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_MEMBLT);
if (!update_check_flush(context,
headerLength + update_approximate_memblt_order(&orderInfo, memblt)))
return FALSE;
wStream* s = update->us;
if (!s)
return FALSE;
@ -1717,9 +1719,12 @@ static BOOL update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyp
WINPR_ASSERT(glyph_index);
rdp_update_internal* update = update_cast(context->update);
const int headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_GLYPH_INDEX);
const size_t headerLength =
update_prepare_order_info(context, &orderInfo, ORDER_TYPE_GLYPH_INDEX);
const size_t inf = update_approximate_glyph_index_order(&orderInfo, glyph_index);
update_check_flush(context, headerLength + inf);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
@ -1754,7 +1759,9 @@ static BOOL update_send_cache_bitmap(rdpContext* context, const CACHE_BITMAP_ORD
: ORDER_TYPE_BITMAP_UNCOMPRESSED;
const size_t inf =
update_approximate_cache_bitmap_order(cache_bitmap, cache_bitmap->compressed, &extraFlags);
update_check_flush(context, headerLength + inf);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
@ -1800,9 +1807,11 @@ static BOOL update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD
if (context->settings->NoBitmapCompressionHeader)
cache_bitmap_v2->flags |= CBR2_NO_BITMAP_COMPRESSION_HDR;
update_check_flush(context, headerLength +
update_approximate_cache_bitmap_v2_order(
cache_bitmap_v2, cache_bitmap_v2->compressed, &extraFlags));
if (!update_check_flush(
context, headerLength + update_approximate_cache_bitmap_v2_order(
cache_bitmap_v2, cache_bitmap_v2->compressed, &extraFlags)))
return FALSE;
wStream* s = update->us;
if (!s)
@ -1844,8 +1853,10 @@ static BOOL update_send_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORD
rdp_update_internal* update = update_cast(context->update);
const BYTE orderType = ORDER_TYPE_BITMAP_COMPRESSED_V3;
update_check_flush(context, headerLength + update_approximate_cache_bitmap_v3_order(
cache_bitmap_v3, &extraFlags));
if (!update_check_flush(context, headerLength + update_approximate_cache_bitmap_v3_order(
cache_bitmap_v3, &extraFlags)))
return FALSE;
wStream* s = update->us;
if (!s)
@ -1887,7 +1898,9 @@ static BOOL update_send_cache_color_table(rdpContext* context,
rdp_update_internal* update = update_cast(context->update);
const size_t inf = update_approximate_cache_color_table_order(cache_color_table, &flags);
update_check_flush(context, headerLength + inf);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
@ -1927,7 +1940,9 @@ static BOOL update_send_cache_glyph(rdpContext* context, const CACHE_GLYPH_ORDER
rdp_update_internal* update = update_cast(context->update);
const size_t inf = update_approximate_cache_glyph_order(cache_glyph, &flags);
update_check_flush(context, headerLength + inf);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
@ -1968,7 +1983,9 @@ static BOOL update_send_cache_glyph_v2(rdpContext* context,
rdp_update_internal* update = update_cast(context->update);
const size_t inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, &flags);
update_check_flush(context, headerLength + inf);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
@ -2008,7 +2025,9 @@ static BOOL update_send_cache_brush(rdpContext* context, const CACHE_BRUSH_ORDER
rdp_update_internal* update = update_cast(context->update);
const size_t inf = update_approximate_cache_brush_order(cache_brush, &flags);
update_check_flush(context, headerLength + inf);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
@ -2047,31 +2066,23 @@ static BOOL update_send_cache_brush(rdpContext* context, const CACHE_BRUSH_ORDER
static BOOL update_send_create_offscreen_bitmap_order(
rdpContext* context, const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
{
wStream* s = NULL;
size_t bm = 0;
size_t em = 0;
size_t inf = 0;
BYTE orderType = 0;
BYTE controlFlags = 0;
size_t headerLength = 0;
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(create_offscreen_bitmap);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
headerLength = 1;
orderType = ORDER_TYPE_CREATE_OFFSCREEN_BITMAP;
controlFlags = ORDER_SECONDARY | (orderType << 2);
inf = update_approximate_create_offscreen_bitmap_order(create_offscreen_bitmap);
update_check_flush(context, headerLength + inf);
const size_t headerLength = 1;
const size_t orderType = ORDER_TYPE_CREATE_OFFSCREEN_BITMAP;
const size_t controlFlags = ORDER_SECONDARY | (orderType << 2);
const size_t inf = update_approximate_create_offscreen_bitmap_order(create_offscreen_bitmap);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
s = update->us;
wStream* s = update->us;
if (!s)
return FALSE;
bm = Stream_GetPosition(s);
const size_t bm = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
@ -2081,7 +2092,7 @@ static BOOL update_send_create_offscreen_bitmap_order(
if (!update_write_create_offscreen_bitmap_order(s, create_offscreen_bitmap))
return FALSE;
em = Stream_GetPosition(s);
const size_t em = Stream_GetPosition(s);
Stream_SetPosition(s, bm);
Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */
Stream_SetPosition(s, em);
@ -2092,30 +2103,23 @@ static BOOL update_send_create_offscreen_bitmap_order(
static BOOL update_send_switch_surface_order(rdpContext* context,
const SWITCH_SURFACE_ORDER* switch_surface)
{
wStream* s = NULL;
size_t bm = 0;
size_t em = 0;
size_t inf = 0;
BYTE orderType = 0;
BYTE controlFlags = 0;
size_t headerLength = 0;
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(switch_surface);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
headerLength = 1;
orderType = ORDER_TYPE_SWITCH_SURFACE;
controlFlags = ORDER_SECONDARY | (orderType << 2);
inf = update_approximate_switch_surface_order(switch_surface);
update_check_flush(context, headerLength + inf);
s = update->us;
const size_t headerLength = 1;
const size_t orderType = ORDER_TYPE_SWITCH_SURFACE;
const size_t controlFlags = ORDER_SECONDARY | (orderType << 2);
const size_t inf = update_approximate_switch_surface_order(switch_surface);
if (!update_check_flush(context, headerLength + inf))
return FALSE;
wStream* s = update->us;
if (!s)
return FALSE;
bm = Stream_GetPosition(s);
const size_t bm = Stream_GetPosition(s);
if (!Stream_EnsureRemainingCapacity(s, headerLength))
return FALSE;
@ -2125,7 +2129,7 @@ static BOOL update_send_switch_surface_order(rdpContext* context,
if (!update_write_switch_surface_order(s, switch_surface))
return FALSE;
em = Stream_GetPosition(s);
const size_t em = Stream_GetPosition(s);
Stream_SetPosition(s, bm);
Stream_Write_UINT8(s, controlFlags); /* controlFlags (1 byte) */
Stream_SetPosition(s, em);
@ -2517,20 +2521,19 @@ static BOOL update_send_new_or_existing_window(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
const WINDOW_STATE_ORDER* stateOrder)
{
wStream* s = NULL;
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
UINT16 orderSize = update_calculate_new_or_existing_window(orderInfo, stateOrder);
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(orderInfo);
WINPR_ASSERT(stateOrder);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
update_check_flush(context, orderSize);
if (!update_check_flush(context, orderSize))
return FALSE;
s = update->us;
wStream* s = update->us;
if (!s)
return FALSE;
@ -2697,23 +2700,22 @@ static UINT16 update_calculate_window_icon_order(const WINDOW_ORDER_INFO* orderI
static BOOL update_send_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
const WINDOW_ICON_ORDER* iconOrder)
{
wStream* s = NULL;
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
WINPR_ASSERT(iconOrder);
ICON_INFO* iconInfo = iconOrder->iconInfo;
UINT16 orderSize = update_calculate_window_icon_order(orderInfo, iconOrder);
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(orderInfo);
WINPR_ASSERT(iconInfo);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
update_check_flush(context, orderSize);
if (!update_check_flush(context, orderSize))
return FALSE;
s = update->us;
wStream* s = update->us;
if (!s || !iconInfo)
return FALSE;
@ -2756,23 +2758,22 @@ static BOOL update_send_window_icon(rdpContext* context, const WINDOW_ORDER_INFO
static BOOL update_send_window_cached_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
const WINDOW_CACHED_ICON_ORDER* cachedIconOrder)
{
wStream* s = NULL;
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
UINT16 orderSize = 14;
WINPR_ASSERT(cachedIconOrder);
const CACHED_ICON_INFO* cachedIcon = &cachedIconOrder->cachedIcon;
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(orderInfo);
WINPR_ASSERT(cachedIcon);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
update_check_flush(context, orderSize);
if (!update_check_flush(context, orderSize))
return FALSE;
s = update->us;
wStream* s = update->us;
if (!s)
return FALSE;
@ -2793,18 +2794,17 @@ static BOOL update_send_window_cached_icon(rdpContext* context, const WINDOW_ORD
static BOOL update_send_window_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
{
wStream* s = NULL;
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
UINT16 orderSize = 11;
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(orderInfo);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
update_check_flush(context, orderSize);
if (!update_check_flush(context, orderSize))
return FALSE;
s = update->us;
wStream* s = update->us;
if (!s)
return FALSE;
@ -2871,21 +2871,20 @@ update_send_new_or_existing_notification_icons(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
const NOTIFY_ICON_STATE_ORDER* iconStateOrder)
{
wStream* s = NULL;
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
BOOL versionFieldPresent = FALSE;
const UINT16 orderSize =
update_calculate_new_or_existing_notification_icons_order(orderInfo, iconStateOrder);
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(orderInfo);
WINPR_ASSERT(iconStateOrder);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
update_check_flush(context, orderSize);
if (!update_check_flush(context, orderSize))
return FALSE;
s = update->us;
wStream* s = update->us;
if (!s)
return FALSE;
@ -2987,18 +2986,17 @@ static BOOL update_send_notify_icon_update(rdpContext* context, const WINDOW_ORD
static BOOL update_send_notify_icon_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo)
{
wStream* s = NULL;
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
UINT16 orderSize = 15;
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(orderInfo);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
update_check_flush(context, orderSize);
if (!update_check_flush(context, orderSize))
return FALSE;
s = update->us;
wStream* s = update->us;
if (!s)
return FALSE;
@ -3037,20 +3035,19 @@ static UINT16 update_calculate_monitored_desktop(const WINDOW_ORDER_INFO* orderI
static BOOL update_send_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo,
const MONITORED_DESKTOP_ORDER* monitoredDesktop)
{
wStream* s = NULL;
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
UINT16 orderSize = update_calculate_monitored_desktop(orderInfo, monitoredDesktop);
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(orderInfo);
WINPR_ASSERT(monitoredDesktop);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
update_check_flush(context, orderSize);
if (!update_check_flush(context, orderSize))
return FALSE;
s = update->us;
wStream* s = update->us;
if (!s)
return FALSE;
@ -3082,18 +3079,17 @@ static BOOL update_send_monitored_desktop(rdpContext* context, const WINDOW_ORDE
static BOOL update_send_non_monitored_desktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
{
wStream* s = NULL;
BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2);
UINT16 orderSize = 7;
rdp_update_internal* update = NULL;
WINPR_ASSERT(context);
WINPR_ASSERT(orderInfo);
update = update_cast(context->update);
rdp_update_internal* update = update_cast(context->update);
update_check_flush(context, orderSize);
if (!update_check_flush(context, orderSize))
return FALSE;
s = update->us;
wStream* s = update->us;
if (!s)
return FALSE;

View File

@ -333,6 +333,8 @@ BOOL per_read_integer16(wStream* s, UINT16* integer, UINT16 min)
BOOL per_write_integer16(wStream* s, UINT16 integer, UINT16 min)
{
if (min > integer)
return FALSE;
if (!Stream_EnsureRemainingCapacity(s, 2))
return FALSE;
Stream_Write_UINT16_BE(s, integer - min);

View File

@ -39,6 +39,7 @@ extern "C"
{ \
WINPR_PRAGMA_DIAG_PUSH \
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
if (!(cond)) \
winpr_int_assert(#cond, __FILE__, __func__, __LINE__); \
WINPR_PRAGMA_DIAG_POP \
@ -58,7 +59,15 @@ extern "C"
#endif
#else
#define WINPR_ASSERT(cond) assert(cond)
#define WINPR_ASSERT(cond) \
do \
{ \
WINPR_PRAGMA_DIAG_PUSH \
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
assert(cond); \
WINPR_PRAGMA_DIAG_POP \
} while (0)
#endif
#ifdef __cplusplus

View File

@ -87,6 +87,12 @@
version \
3.9.0 \
*/
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
_Pragma( \
"clang diagnostic ignored \"-Wtautological-value-range-compare\"") /** @since \
version \
3.10.0 \
*/
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \
_Pragma("clang diagnostic ignored \"-Wformat-nonliteral\"") /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC /** @since version 3.3.0 */ /* not supported \
@ -119,6 +125,8 @@
_Pragma("GCC diagnostic ignored \"-Wformat-security\"")
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE /* not supported
_Pragma("GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"") */ /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE /* not supported
_Pragma("GCC diagnostic ignored \"-Wtautological-value-range-compare\"") */ /** @since version 3.10.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \
_Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") /** @since version 3.9.0 */
#if __GNUC__ >= 11
@ -144,6 +152,7 @@
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE /** @since version 3.10.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC /** @since version 3.3.0 */
#define WINPR_PRAGMA_DIAG_POP

View File

@ -790,97 +790,270 @@ extern "C"
memcpy(_b, (_s->pointer), (_n));
}
static INLINE void Stream_Write_UINT8(wStream* _s, UINT8 _v)
#define Stream_Write_INT8(s, v) \
do \
{ \
WINPR_ASSERT((v) <= INT8_MAX); \
WINPR_ASSERT((v) >= INT8_MIN); \
Stream_Write_INT8_unchecked((s), (v)) \
} while (0)
/** @brief writes a \b INT8 to a \b wStream. The stream must be large enough to hold the data.
*
* Do not use directly, use the define @ref Stream_Write_INT8 instead
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_INT8_unchecked(wStream* _s, INT8 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 1);
*_s->pointer++ = (_v);
*_s->pointer++ = WINPR_STREAM_CAST(BYTE, _v);
}
static INLINE void Stream_Write_INT16(wStream* _s, INT16 _v)
#define Stream_Write_UINT8(s, v) \
do \
{ \
WINPR_ASSERT((v) <= UINT8_MAX); \
WINPR_ASSERT((v) >= 0); \
Stream_Write_UINT8_unchecked((s), (v)); \
} while (0)
/** @brief writes a \b UINT8 to a \b wStream. The stream must be large enough to hold the data.
*
* Do not use directly, use the define @ref Stream_Write_UINT8 instead
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_UINT8_unchecked(wStream* _s, UINT8 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 1);
*_s->pointer++ = WINPR_STREAM_CAST(BYTE, _v);
}
#define Stream_Write_INT16(s, v) \
do \
{ \
WINPR_ASSERT((v) >= INT16_MIN); \
WINPR_ASSERT((v) <= INT16_MAX); \
Stream_Write_INT16_unchecked((s), (v)); \
} while (0)
/** @brief writes a \b INT16 as \b little endian to a \b wStream. The stream must be large
* enough to hold the data.
*
* Do not use directly, use the define @ref Stream_Write_INT16 instead
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_INT16_unchecked(wStream* _s, INT16 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 2);
*_s->pointer++ = (_v)&0xFF;
*_s->pointer++ = (_v) & 0xFF;
*_s->pointer++ = ((_v) >> 8) & 0xFF;
}
static INLINE void Stream_Write_UINT16(wStream* _s, UINT16 _v)
#define Stream_Write_UINT16(s, v) \
do \
{ \
WINPR_ASSERT((v) <= UINT16_MAX); \
WINPR_ASSERT((v) >= 0); \
Stream_Write_UINT16_unchecked((s), (v)); \
} while (0)
/** @brief writes a \b UINT16 as \b little endian to a \b wStream. The stream must be large
* enough to hold the data.
*
* Do not use directly, use the define @ref Stream_Write_UINT16 instead
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_UINT16_unchecked(wStream* _s, UINT16 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 2);
*_s->pointer++ = (_v)&0xFF;
*_s->pointer++ = (_v) & 0xFF;
*_s->pointer++ = ((_v) >> 8) & 0xFF;
}
static INLINE void Stream_Write_UINT16_BE(wStream* _s, UINT16 _v)
#define Stream_Write_UINT16_BE(s, v) \
do \
{ \
WINPR_ASSERT((v) <= UINT16_MAX); \
WINPR_ASSERT((v) >= 0); \
Stream_Write_UINT16_BE_unchecked((s), (v)); \
} while (0)
/** @brief writes a \b UINT16 as \b big endian to a \b wStream. The stream must be large enough
* to hold the data.
*
* Do not use directly, use the define @ref Stream_Write_UINT16_BE instead
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_UINT16_BE_unchecked(wStream* _s, UINT16 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 2);
*_s->pointer++ = ((_v) >> 8) & 0xFF;
*_s->pointer++ = (_v)&0xFF;
*_s->pointer++ = (_v) & 0xFF;
}
static INLINE void Stream_Write_UINT24_BE(wStream* _s, UINT32 _v)
#define Stream_Write_UINT24_BE(s, v) \
do \
{ \
WINPR_ASSERT((v) <= 0xFFFFFF); \
WINPR_ASSERT((v) >= 0); \
Stream_Write_UINT24_BE_unchecked((s), (v)); \
} while (0)
/** @brief writes a \b UINT24 as \b big endian to a \b wStream. The stream must be large enough
* to hold the data.
*
* Do not use directly, use the define @ref Stream_Write_UINT24_BE instead
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_UINT24_BE_unchecked(wStream* _s, UINT32 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(_v <= 0x00FFFFFF);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 3);
*_s->pointer++ = ((_v) >> 16) & 0xFF;
*_s->pointer++ = ((_v) >> 8) & 0xFF;
*_s->pointer++ = (_v)&0xFF;
*_s->pointer++ = (_v) & 0xFF;
}
static INLINE void Stream_Write_INT32(wStream* _s, INT32 _v)
#define Stream_Write_INT32(s, v) \
do \
{ \
WINPR_ASSERT((v) <= INT32_MAX); \
WINPR_ASSERT((v) >= INT32_MIN); \
Stream_Write_INT32_unchecked((s), (v)); \
} while (0)
/** @brief writes a \b INT32 as \b little endian to a \b wStream. The stream must be large
* enough to hold the data.
*
* Do not use directly, use the define @ref Stream_Write_INT32 instead
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_INT32_unchecked(wStream* _s, INT32 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 4);
*_s->pointer++ = (_v)&0xFF;
*_s->pointer++ = (_v) & 0xFF;
*_s->pointer++ = ((_v) >> 8) & 0xFF;
*_s->pointer++ = ((_v) >> 16) & 0xFF;
*_s->pointer++ = ((_v) >> 24) & 0xFF;
}
static INLINE void Stream_Write_UINT32(wStream* _s, UINT32 _v)
#define Stream_Write_UINT32(s, v) \
do \
{ \
WINPR_ASSERT((v) <= UINT32_MAX); \
WINPR_ASSERT((v) >= 0); \
Stream_Write_UINT32_unchecked((s), (v)); \
} while (0)
/** @brief writes a \b UINT32 as \b little endian to a \b wStream. The stream must be large
* enough to hold the data.
*
* Do not use directly, use the define @ref Stream_Write_UINT32 instead
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_UINT32_unchecked(wStream* _s, UINT32 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 4);
*_s->pointer++ = (_v)&0xFF;
*_s->pointer++ = (_v) & 0xFF;
*_s->pointer++ = ((_v) >> 8) & 0xFF;
*_s->pointer++ = ((_v) >> 16) & 0xFF;
*_s->pointer++ = ((_v) >> 24) & 0xFF;
}
static INLINE void Stream_Write_UINT32_BE(wStream* _s, UINT32 _v)
#define Stream_Write_UINT32_BE(s, v) \
do \
{ \
WINPR_ASSERT((v) <= UINT32_MAX); \
WINPR_ASSERT((v) >= 0); \
Stream_Write_UINT32_BE_unchecked((s), (v)); \
} while (0)
/** @brief writes a \b UINT32 as \b big endian to a \b wStream. The stream must be large enough
* to hold the data.
*
* Do not use directly, use the define @ref Stream_Write_UINT32_BE instead
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_UINT32_BE_unchecked(wStream* _s, UINT32 _v)
{
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 4);
Stream_Write_UINT16_BE(_s, ((_v) >> 16 & 0xFFFF));
Stream_Write_UINT16_BE(_s, ((_v)&0xFFFF));
Stream_Write_UINT16_BE(_s, ((_v) & 0xFFFF));
}
/** @brief writes a \b UINT64 as \b little endian to a \b wStream. The stream must be large
* enough to hold the data.
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_UINT64(wStream* _s, UINT64 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 8);
Stream_Write_UINT32(_s, ((_v)&0xFFFFFFFFUL));
Stream_Write_UINT32(_s, ((_v) & 0xFFFFFFFFUL));
Stream_Write_UINT32(_s, ((_v) >> 16 & 0xFFFFFFFFUL));
}
/** @brief writes a \b UINT64 as \b big endian to a \b wStream. The stream must be large enough
* to hold the data.
*
* \param _s The stream to write to, must not be \b NULL
* \param _v The value to write
*/
static INLINE void Stream_Write_UINT64_BE(wStream* _s, UINT64 _v)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(_s->pointer);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 8);
Stream_Write_UINT32_BE(_s, ((_v) >> 16 & 0xFFFFFFFFUL));
Stream_Write_UINT32_BE(_s, ((_v)&0xFFFFFFFFUL));
Stream_Write_UINT32_BE(_s, ((_v) & 0xFFFFFFFFUL));
}
static INLINE void Stream_Write(wStream* _s, const void* _b, size_t _n)
@ -929,14 +1102,6 @@ extern "C"
Stream_Rewind(_s, sizeof(UINT64));
}
static INLINE void Stream_Zero(wStream* _s, size_t _n)
{
WINPR_ASSERT(_s);
WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= (_n));
memset(_s->pointer, '\0', (_n));
Stream_Seek(_s, _n);
}
static INLINE void Stream_Fill(wStream* _s, int _v, size_t _n)
{
WINPR_ASSERT(_s);
@ -945,6 +1110,11 @@ extern "C"
Stream_Seek(_s, _n);
}
static INLINE void Stream_Zero(wStream* _s, size_t _n)
{
Stream_Fill(_s, '\0', _n);
}
static INLINE void Stream_Copy(wStream* _src, wStream* _dst, size_t _n)
{
WINPR_ASSERT(_src);