Fix users of Stream_GetPosition() that returns size_t

This commit is contained in:
David Fort 2017-12-11 10:25:21 +01:00
parent 11ee81be60
commit 41823080f9
26 changed files with 77 additions and 75 deletions

View File

@ -42,7 +42,7 @@
UINT cliprdr_process_format_list(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags)
{
UINT32 index;
UINT32 position;
size_t position;
BOOL asciiNames;
int formatNameLength;
char* szFormatName;

View File

@ -89,7 +89,7 @@ static wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags,
*/
static UINT cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
{
UINT32 pos;
size_t pos;
UINT32 dataLen;
UINT status = CHANNEL_RC_OK;
pos = Stream_GetPosition(s);

View File

@ -91,7 +91,7 @@ wStream* cliprdr_server_packet_new(UINT16 msgType, UINT16 msgFlags,
*/
UINT cliprdr_server_packet_send(CliprdrServerPrivate* cliprdr, wStream* s)
{
UINT32 pos;
size_t pos;
BOOL status;
UINT32 dataLen;
UINT32 written;
@ -628,7 +628,7 @@ static UINT cliprdr_server_receive_format_list(CliprdrServerContext* context,
{
UINT32 index;
UINT32 dataLen;
UINT32 position;
size_t position;
BOOL asciiNames;
int formatNameLength;
char* szFormatName;
@ -1185,7 +1185,7 @@ static UINT cliprdr_server_init(CliprdrServerContext* context)
UINT cliprdr_server_read(CliprdrServerContext* context)
{
wStream* s;
int position;
size_t position;
DWORD BytesToRead;
DWORD BytesReturned;
CLIPRDR_HEADER header;

View File

@ -727,7 +727,7 @@ static UINT drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId,
const BYTE* data, UINT32 dataSize)
{
wStream* data_out;
unsigned long pos;
size_t pos;
UINT32 cbChId;
UINT32 cbLen;
unsigned long chunkLength;
@ -916,7 +916,7 @@ static UINT32 drdynvc_read_variable_uint(wStream* s, int cbLen)
static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp,
int cbChId, wStream* s)
{
unsigned long pos;
size_t pos;
UINT status;
UINT32 ChannelId;
wStream* data_out;

View File

@ -1193,12 +1193,12 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
{
int i;
BYTE c;
int pos;
size_t pos;
int index;
wStream* s;
UINT32 count;
int data_len;
int count_pos;
size_t data_len;
size_t count_pos;
DEVICE* device;
int keyCount;
ULONG_PTR* pKeys;
@ -1212,7 +1212,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
Stream_Write_UINT16(s, RDPDR_CTYP_CORE); /* Component (2 bytes) */
Stream_Write_UINT16(s, PAKID_CORE_DEVICELIST_ANNOUNCE); /* PacketId (2 bytes) */
count_pos = (int) Stream_GetPosition(s);
count_pos = Stream_GetPosition(s);
count = 0;
Stream_Seek_UINT32(s); /* deviceCount */
pKeys = NULL;
@ -1233,7 +1233,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
if ((rdpdr->versionMinor == 0x0005) ||
(device->type == RDPDR_DTYP_SMARTCARD) || userLoggedOn)
{
data_len = (int)(device->data == NULL ? 0 : Stream_GetPosition(device->data));
data_len = (device->data == NULL ? 0 : Stream_GetPosition(device->data));
if (!Stream_EnsureRemainingCapacity(s, 20 + data_len))
{
@ -1267,7 +1267,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
}
free(pKeys);
pos = (int) Stream_GetPosition(s);
pos = Stream_GetPosition(s);
Stream_SetPosition(s, count_pos);
Stream_Write_UINT32(s, count);
Stream_SetPosition(s, pos);

View File

@ -1138,7 +1138,7 @@ static UINT rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callb
*/
static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
int beg, end;
size_t beg, end;
RDPGFX_HEADER header;
UINT error;
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;

View File

@ -1252,7 +1252,7 @@ static UINT rdpgfx_recv_qoe_frame_acknowledge_pdu(RdpgfxServerContext* context,
*/
static UINT rdpgfx_server_receive_pdu(RdpgfxServerContext* context, wStream* s)
{
int beg, end;
size_t beg, end;
RDPGFX_HEADER header;
UINT error = CHANNEL_RC_OK;
beg = Stream_GetPosition(s);

View File

@ -42,7 +42,7 @@
*/
UINT rdpsnd_server_send_formats(RdpsndServerContext* context, wStream* s)
{
int pos;
size_t pos;
UINT16 i;
BOOL status;
ULONG written;
@ -574,10 +574,11 @@ out:
static UINT rdpsnd_server_set_volume(RdpsndServerContext* context, int left,
int right)
{
int pos;
size_t pos;
BOOL status;
ULONG written;
wStream* s = context->priv->rdpsnd_pdu;
Stream_Write_UINT8(s, SNDC_SETVOLUME);
Stream_Write_UINT8(s, 0);
Stream_Seek_UINT16(s);
@ -600,7 +601,7 @@ static UINT rdpsnd_server_set_volume(RdpsndServerContext* context, int left,
*/
static UINT rdpsnd_server_close(RdpsndServerContext* context)
{
int pos;
size_t pos;
BOOL status;
ULONG written;
wStream* s = context->priv->rdpsnd_pdu;

View File

@ -482,7 +482,7 @@ UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
int num_rects = 0;
UINT error = CHANNEL_RC_OK;
int i;
int pos;
size_t pos;
if (Stream_GetRemainingLength(ifman->input) < GUID_SIZE + 32)
return ERROR_INVALID_DATA;

View File

@ -123,7 +123,7 @@ BOOL tsmf_playback_ack(IWTSVirtualChannelCallback *pChannelCallback,
*/
static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *data)
{
int length;
size_t length;
wStream *input;
wStream *output;
UINT error = CHANNEL_RC_OK;

View File

@ -470,7 +470,7 @@ int freerdp_bitmap_compress(const char* srcData, int width, int height,
int bicolor2;
int bicolor_spin;
int end;
int i;
size_t i;
int out_count;
int ypixel;
int last_ypixel;

View File

@ -756,7 +756,7 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context,
{
BOOL rc;
int i, close_cnt;
int pos;
size_t pos;
BYTE quant;
RFX_TILE* tile;
UINT32* quants;
@ -999,7 +999,7 @@ BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data, UINT32 length,
UINT32 dstStride, UINT32 dstHeight,
REGION16* invalidRegion)
{
int pos;
size_t pos;
REGION16 updateRegion;
UINT32 blockLen;
UINT32 blockType;

View File

@ -141,7 +141,8 @@ static void rdp_write_capability_set_header(wStream* s, UINT16 length,
static int rdp_capability_set_start(wStream* s)
{
int header;
size_t header;
header = Stream_GetPosition(s);
Stream_Zero(s, CAPSET_HEADER_LENGTH);
return header;
@ -149,8 +150,9 @@ static int rdp_capability_set_start(wStream* s)
static void rdp_capability_set_finish(wStream* s, int header, UINT16 type)
{
int footer;
size_t footer;
UINT16 length;
footer = Stream_GetPosition(s);
length = footer - header;
Stream_SetPosition(s, header);
@ -3880,7 +3882,7 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s)
BOOL rdp_write_demand_active(wStream* s, rdpSettings* settings)
{
int bm, em, lm;
size_t bm, em, lm;
UINT16 numberCapabilities;
UINT16 lengthCombinedCapabilities;
@ -4034,7 +4036,7 @@ BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s)
BOOL rdp_write_confirm_active(wStream* s, rdpSettings* settings)
{
int bm, em, lm;
size_t bm, em, lm;
UINT16 numberCapabilities;
UINT16 lengthSourceDescriptor;
UINT16 lengthCombinedCapabilities;

View File

@ -451,7 +451,7 @@ static int fastpath_recv_update_data(rdpFastPath* fastpath, wStream* s)
int status;
UINT16 size;
rdpRdp* rdp;
int next_pos;
size_t next_pos;
wStream* cs;
int bulkStatus;
UINT32 totalSize;

View File

@ -628,7 +628,7 @@ HttpResponse* http_response_recv(rdpTls* tls)
int size;
int count;
int status;
int position;
size_t position;
char* line;
char* buffer;
char* header = NULL;

View File

@ -333,7 +333,7 @@ BOOL gcc_read_client_data_blocks(wStream* s, rdpMcs* mcs, int length)
{
UINT16 type;
UINT16 blockLength;
int begPos, endPos;
size_t begPos, endPos;
while (length > 0)
{

View File

@ -233,7 +233,7 @@ wStream* license_send_stream_init(rdpLicense* license)
BOOL license_send(rdpLicense* license, wStream* s, BYTE type)
{
int length;
size_t length;
BYTE flags;
UINT16 wMsgSize;
rdpRdp* rdp = license->rdp;

View File

@ -325,7 +325,7 @@ static BOOL mcs_read_domain_parameters(wStream* s, DomainParameters* domainParam
static BOOL mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters)
{
int length;
size_t length;
wStream* tmps;
if (!s || !domainParameters)
@ -672,9 +672,9 @@ out:
BOOL mcs_send_connect_initial(rdpMcs* mcs)
{
int status = -1;
int length;
size_t length;
wStream* s = NULL;
int bm, em;
size_t bm, em;
wStream* gcc_CCrq = NULL;
wStream* client_data = NULL;
@ -782,10 +782,10 @@ BOOL mcs_recv_connect_response(rdpMcs* mcs, wStream* s)
BOOL mcs_send_connect_response(rdpMcs* mcs)
{
int length;
size_t length;
int status;
wStream* s;
int bm, em;
size_t bm, em;
wStream* gcc_CCrsp;
wStream* server_data;

View File

@ -665,7 +665,7 @@ static BOOL nego_read_request_token_or_cookie(rdpNego* nego, wStream* s)
BYTE *str = NULL;
UINT16 crlf = 0;
int pos, len;
size_t pos, len;
BOOL result = FALSE;
BOOL isToken = FALSE;
@ -808,7 +808,7 @@ BOOL nego_send_negotiation_request(rdpNego* nego)
{
wStream* s;
int length;
int bm, em;
size_t bm, em;
BYTE flags = 0;
int cookie_length;
@ -834,7 +834,7 @@ BOOL nego_send_negotiation_request(rdpNego* nego)
(nego->RoutingToken[nego->RoutingTokenLength - 1] == 0x0A))
{
WLog_DBG(TAG, "Routing token looks correctly terminated - use verbatim");
length +=nego->RoutingTokenLength;
length += nego->RoutingTokenLength;
}
else
{
@ -997,7 +997,7 @@ void nego_process_negotiation_failure(rdpNego* nego, wStream* s)
BOOL nego_send_negotiation_response(rdpNego* nego)
{
int length;
int bm, em;
size_t bm, em;
BOOL status;
wStream* s;
BYTE flags;

View File

@ -557,7 +557,7 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id)
{
UINT16 length;
UINT32 sec_bytes;
int sec_hold;
size_t sec_hold;
UINT32 pad;
length = Stream_GetPosition(s);
@ -584,9 +584,9 @@ BOOL rdp_send_pdu(rdpRdp* rdp, wStream* s, UINT16 type, UINT16 channel_id)
BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id)
{
UINT16 length;
size_t length;
UINT32 sec_bytes;
int sec_hold;
size_t sec_hold;
UINT32 pad;
length = Stream_GetPosition(s);
@ -604,7 +604,8 @@ BOOL rdp_send_data_pdu(rdpRdp* rdp, wStream* s, BYTE type, UINT16 channel_id)
Stream_SetPosition(s, length);
Stream_SealLength(s);
WLog_DBG(TAG, "%s: sending data (type=0x%x size=%d channelId=%d)", __FUNCTION__, type, Stream_Length(s), channel_id);
WLog_DBG(TAG, "%s: sending data (type=0x%x size=%"PRIuz" channelId=%"PRIu16")", __FUNCTION__,
type, Stream_Length(s), channel_id);
if (transport_write(rdp->transport, s) < 0)
return FALSE;
@ -615,7 +616,7 @@ BOOL rdp_send_message_channel_pdu(rdpRdp* rdp, wStream* s, UINT16 sec_flags)
{
UINT16 length;
UINT32 sec_bytes;
int sec_hold;
size_t sec_hold;
UINT32 pad;
length = Stream_GetPosition(s);
@ -1139,7 +1140,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
UINT16 pduSource;
UINT16 channelId = 0;
UINT16 securityFlags = 0;
int nextPosition;
size_t nextPosition;
if (!rdp_read_header(rdp, s, &length, &channelId))
{

View File

@ -30,7 +30,7 @@
static BOOL update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT32* length)
{
int pos;
size_t pos;
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
if (Stream_GetRemainingLength(s) < 20)

View File

@ -161,8 +161,8 @@ void tpdu_write_connection_request(wStream* s, UINT16 length)
BOOL tpdu_read_connection_confirm(wStream* s, BYTE* li)
{
BYTE code;
int position;
int bytes_read = 0;
size_t position;
size_t bytes_read = 0;
/* save the position to determine the number of bytes read */
position = Stream_GetPosition(s);

View File

@ -642,7 +642,7 @@ static int transport_read_layer_bytes(rdpTransport* transport, wStream* s,
int transport_read_pdu(rdpTransport* transport, wStream* s)
{
int status;
int position;
size_t position;
int pduLength;
BYTE* header;
pduLength = 0;
@ -767,8 +767,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
if (!Stream_EnsureCapacity(s, Stream_GetPosition(s) + pduLength))
return -1;
status = transport_read_layer_bytes(transport, s,
pduLength - Stream_GetPosition(s));
status = transport_read_layer_bytes(transport, s, pduLength - Stream_GetPosition(s));
if (status != 1)
return status;
@ -784,7 +783,7 @@ int transport_read_pdu(rdpTransport* transport, wStream* s)
int transport_write(rdpTransport* transport, wStream* s)
{
int length;
size_t length;
int status = -1;
int writtenlength = 0;

View File

@ -835,7 +835,7 @@ static int update_prepare_order_info(rdpContext* context,
int update_write_order_info(rdpContext* context, wStream* s,
ORDER_INFO* orderInfo, int offset)
{
int position;
size_t position;
position = Stream_GetPosition(s);
Stream_SetPosition(s, offset);
Stream_Write_UINT8(s, orderInfo->controlFlags); /* controlFlags (1 byte) */
@ -1188,7 +1188,7 @@ static BOOL update_send_dstblt(rdpContext* context,
static BOOL update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt)
{
wStream* s;
int offset;
size_t offset;
int headerLength;
ORDER_INFO orderInfo;
rdpUpdate* update = context->update;
@ -1246,7 +1246,7 @@ static BOOL update_send_opaque_rect(rdpContext* context,
const OPAQUE_RECT_ORDER* opaque_rect)
{
wStream* s;
int offset;
size_t offset;
int headerLength;
ORDER_INFO orderInfo;
rdpUpdate* update = context->update;
@ -1304,7 +1304,7 @@ static BOOL update_send_line_to(rdpContext* context,
static BOOL update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
{
wStream* s;
int offset;
size_t offset;
int headerLength;
ORDER_INFO orderInfo;
rdpUpdate* update = context->update;
@ -1333,7 +1333,7 @@ static BOOL update_send_glyph_index(rdpContext* context,
GLYPH_INDEX_ORDER* glyph_index)
{
wStream* s;
int offset;
size_t offset;
int headerLength;
int inf;
ORDER_INFO orderInfo;
@ -1367,7 +1367,7 @@ static BOOL update_send_cache_bitmap(rdpContext* context,
const CACHE_BITMAP_ORDER* cache_bitmap)
{
wStream* s;
int bm, em;
size_t bm, em;
BYTE orderType;
int headerLength;
int inf;
@ -1415,7 +1415,7 @@ static BOOL update_send_cache_bitmap_v2(rdpContext* context,
CACHE_BITMAP_V2_ORDER* cache_bitmap_v2)
{
wStream* s;
int bm, em;
size_t bm, em;
BYTE orderType;
int headerLength;
UINT16 extraFlags;
@ -1465,7 +1465,7 @@ static BOOL update_send_cache_bitmap_v3(rdpContext* context,
CACHE_BITMAP_V3_ORDER* cache_bitmap_v3)
{
wStream* s;
int bm, em;
size_t bm, em;
BYTE orderType;
int headerLength;
UINT16 extraFlags;
@ -1510,7 +1510,7 @@ static BOOL update_send_cache_color_table(rdpContext* context,
{
wStream* s;
UINT16 flags;
int bm, em, inf;
size_t bm, em, inf;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
@ -1551,7 +1551,7 @@ static BOOL update_send_cache_glyph(rdpContext* context,
{
wStream* s;
UINT16 flags;
int bm, em, inf;
size_t bm, em, inf;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
@ -1592,7 +1592,7 @@ static BOOL update_send_cache_glyph_v2(rdpContext* context,
{
wStream* s;
UINT16 flags;
int bm, em, inf;
size_t bm, em, inf;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
@ -1618,8 +1618,7 @@ static BOOL update_send_cache_glyph_v2(rdpContext* context,
em = Stream_GetPosition(s);
orderLength = (em - bm) - 13;
Stream_SetPosition(s, bm);
Stream_Write_UINT8(s, ORDER_STANDARD |
ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT8(s, ORDER_STANDARD | ORDER_SECONDARY); /* controlFlags (1 byte) */
Stream_Write_UINT16(s, orderLength); /* orderLength (2 bytes) */
Stream_Write_UINT16(s, flags); /* extraFlags (2 bytes) */
Stream_Write_UINT8(s, ORDER_TYPE_CACHE_GLYPH); /* orderType (1 byte) */
@ -1633,7 +1632,7 @@ static BOOL update_send_cache_brush(rdpContext* context,
{
wStream* s;
UINT16 flags;
int bm, em, inf;
size_t bm, em, inf;
int headerLength;
INT16 orderLength;
rdpUpdate* update = context->update;
@ -1678,7 +1677,7 @@ static BOOL update_send_create_offscreen_bitmap_order(
const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap)
{
wStream* s;
int bm, em, inf;
size_t bm, em, inf;
BYTE orderType;
BYTE controlFlags;
int headerLength;
@ -1717,7 +1716,7 @@ static BOOL update_send_switch_surface_order(
const SWITCH_SURFACE_ORDER* switch_surface)
{
wStream* s;
int bm, em, inf;
size_t bm, em, inf;
BYTE orderType;
BYTE controlFlags;
int headerLength;

View File

@ -192,7 +192,7 @@ void ntlm_print_message_fields(NTLM_MESSAGE_FIELDS* fields, const char* name)
SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buffer)
{
wStream* s;
int length;
size_t length;
NTLM_NEGOTIATE_MESSAGE* message;
message = &context->NEGOTIATE_MESSAGE;
ZeroMemory(message, sizeof(NTLM_NEGOTIATE_MESSAGE));
@ -261,7 +261,7 @@ SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buf
SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buffer)
{
wStream* s;
int length;
size_t length;
NTLM_NEGOTIATE_MESSAGE* message;
message = &context->NEGOTIATE_MESSAGE;
ZeroMemory(message, sizeof(NTLM_NEGOTIATE_MESSAGE));
@ -503,7 +503,7 @@ SECURITY_STATUS ntlm_read_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer buf
SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer buffer)
{
wStream* s;
int length;
size_t length;
UINT32 PayloadOffset;
NTLM_CHALLENGE_MESSAGE* message;
message = &context->CHALLENGE_MESSAGE;
@ -593,7 +593,7 @@ SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer bu
SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer buffer)
{
wStream* s;
int length;
size_t length;
UINT32 flags;
NTLM_AV_PAIR* AvFlags;
UINT32 PayloadBufferOffset;
@ -784,7 +784,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer buffer)
{
wStream* s;
int length;
size_t length;
UINT32 PayloadBufferOffset;
NTLM_AUTHENTICATE_MESSAGE* message;
SSPI_CREDENTIALS* credentials = context->credentials;

View File

@ -2,7 +2,7 @@
#include <winpr/print.h>
#include <winpr/stream.h>
static BOOL TestStream_Verify(wStream* s, int mincap, int len, int pos)
static BOOL TestStream_Verify(wStream* s, int mincap, int len, size_t pos)
{
if (Stream_Buffer(s) == NULL)
{