freerdp: purge deprecated stream utils
This commit is contained in:
parent
fd230443c5
commit
fdf3ddcf9e
@ -98,11 +98,11 @@ static int audin_process_version(IWTSVirtualChannelCallback* pChannelCallback, w
|
||||
|
||||
DEBUG_DVC("Version=%d", Version);
|
||||
|
||||
out = stream_new(5);
|
||||
out = Stream_New(NULL, 5);
|
||||
Stream_Write_UINT8(out, MSG_SNDIN_VERSION);
|
||||
Stream_Write_UINT32(out, Version);
|
||||
error = callback->channel->Write(callback->channel, Stream_GetPosition(s), Stream_Buffer(s), NULL);
|
||||
stream_free(out);
|
||||
Stream_Free(out, TRUE);
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -140,7 +140,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w
|
||||
callback->formats = (audinFormat*) malloc(NumFormats * sizeof(audinFormat));
|
||||
ZeroMemory(callback->formats, NumFormats * sizeof(audinFormat));
|
||||
|
||||
out = stream_new(9);
|
||||
out = Stream_New(NULL, 9);
|
||||
Stream_Seek(out, 9);
|
||||
|
||||
/* SoundFormats (variable) */
|
||||
@ -190,7 +190,7 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, w
|
||||
Stream_Write_UINT32(out, cbSizeFormatsPacket); /* cbSizeFormatsPacket (4 bytes) */
|
||||
|
||||
error = callback->channel->Write(callback->channel, cbSizeFormatsPacket, Stream_Buffer(out), NULL);
|
||||
stream_free(out);
|
||||
Stream_Free(out, TRUE);
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -201,11 +201,11 @@ static int audin_send_format_change_pdu(IWTSVirtualChannelCallback* pChannelCall
|
||||
wStream* out;
|
||||
AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback;
|
||||
|
||||
out = stream_new(5);
|
||||
out = Stream_New(NULL, 5);
|
||||
Stream_Write_UINT8(out, MSG_SNDIN_FORMATCHANGE);
|
||||
Stream_Write_UINT32(out, NewFormat);
|
||||
error = callback->channel->Write(callback->channel, 5, Stream_Buffer(out), NULL);
|
||||
stream_free(out);
|
||||
Stream_Free(out, TRUE);
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -216,11 +216,11 @@ static int audin_send_open_reply_pdu(IWTSVirtualChannelCallback* pChannelCallbac
|
||||
wStream* out;
|
||||
AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback;
|
||||
|
||||
out = stream_new(5);
|
||||
out = Stream_New(NULL, 5);
|
||||
Stream_Write_UINT8(out, MSG_SNDIN_OPEN_REPLY);
|
||||
Stream_Write_UINT32(out, Result);
|
||||
error = callback->channel->Write(callback->channel, 5, Stream_Buffer(out), NULL);
|
||||
stream_free(out);
|
||||
Stream_Free(out, TRUE);
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -236,11 +236,11 @@ static BOOL audin_receive_wave_data(BYTE* data, int size, void* user_data)
|
||||
if (error != 0)
|
||||
return FALSE;
|
||||
|
||||
out = stream_new(size + 1);
|
||||
out = Stream_New(NULL, size + 1);
|
||||
Stream_Write_UINT8(out, MSG_SNDIN_DATA);
|
||||
Stream_Write(out, data, size);
|
||||
error = callback->channel->Write(callback->channel, Stream_GetPosition(out), Stream_Buffer(out), NULL);
|
||||
stream_free(out);
|
||||
Stream_Free(out, TRUE);
|
||||
|
||||
return (error == 0 ? TRUE : FALSE);
|
||||
}
|
||||
@ -317,8 +317,7 @@ static int audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
wStream* s;
|
||||
BYTE MessageId;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, pBuffer, cbSize);
|
||||
s = Stream_New(pBuffer, cbSize);
|
||||
|
||||
Stream_Read_UINT8(s, MessageId);
|
||||
|
||||
@ -348,8 +347,7 @@ static int audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
break;
|
||||
}
|
||||
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, FALSE);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ static void* audin_server_thread_func(void* arg)
|
||||
break;
|
||||
}
|
||||
|
||||
s = stream_new(4096);
|
||||
s = Stream_New(NULL, 4096);
|
||||
|
||||
if (ready)
|
||||
{
|
||||
@ -381,7 +381,7 @@ static void* audin_server_thread_func(void* arg)
|
||||
}
|
||||
}
|
||||
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
WTSVirtualChannelClose(audin->audin_channel);
|
||||
audin->audin_channel = NULL;
|
||||
|
||||
|
@ -57,7 +57,7 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
|
||||
}
|
||||
else
|
||||
{
|
||||
wStream* body = stream_new(0);
|
||||
wStream* body = Stream_New(NULL, 64);
|
||||
|
||||
for (i = 0; i < cb_event->num_formats; i++)
|
||||
{
|
||||
@ -95,7 +95,7 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
|
||||
|
||||
s = cliprdr_packet_new(CB_FORMAT_LIST, 0, Stream_Capacity(body));
|
||||
Stream_Write(s, Stream_Buffer(body), Stream_Capacity(body));
|
||||
stream_free(body);
|
||||
Stream_Free(body, TRUE);
|
||||
}
|
||||
|
||||
cliprdr_packet_send(cliprdr, s);
|
||||
|
@ -57,7 +57,7 @@ wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, UINT32 dataLen)
|
||||
{
|
||||
wStream* s;
|
||||
|
||||
s = stream_new(dataLen + 8);
|
||||
s = Stream_New(NULL, dataLen + 8);
|
||||
Stream_Write_UINT16(s, msgType);
|
||||
Stream_Write_UINT16(s, msgFlags);
|
||||
/* Write actual length after the entire packet has been constructed. */
|
||||
@ -238,7 +238,7 @@ static void cliprdr_process_receive(rdpSvcPlugin* plugin, wStream* s)
|
||||
break;
|
||||
}
|
||||
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
static void cliprdr_process_event(rdpSvcPlugin* plugin, wMessage* event)
|
||||
|
@ -92,7 +92,7 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN
|
||||
if (drdynvc->channel_error != CHANNEL_RC_OK)
|
||||
return 1;
|
||||
|
||||
data_out = stream_new(CHANNEL_CHUNK_LENGTH);
|
||||
data_out = Stream_New(NULL, CHANNEL_CHUNK_LENGTH);
|
||||
Stream_SetPosition(data_out, 1);
|
||||
cbChId = drdynvc_write_variable_uint(data_out, ChannelId);
|
||||
|
||||
@ -129,7 +129,7 @@ int drdynvc_write_data(drdynvcPlugin* drdynvc, UINT32 ChannelId, BYTE* data, UIN
|
||||
|
||||
while (error == CHANNEL_RC_OK && data_size > 0)
|
||||
{
|
||||
data_out = stream_new(CHANNEL_CHUNK_LENGTH);
|
||||
data_out = Stream_New(NULL, CHANNEL_CHUNK_LENGTH);
|
||||
Stream_SetPosition(data_out, 1);
|
||||
cbChId = drdynvc_write_variable_uint(data_out, ChannelId);
|
||||
|
||||
@ -190,7 +190,7 @@ static int drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp, in
|
||||
Stream_Read_UINT16(s, drdynvc->PriorityCharge3);
|
||||
}
|
||||
|
||||
data_out = stream_new(4);
|
||||
data_out = Stream_New(NULL, 4);
|
||||
Stream_Write_UINT16(data_out, 0x0050); /* Cmd+Sp+cbChId+Pad. Note: MSTSC sends 0x005c */
|
||||
Stream_Write_UINT16(data_out, drdynvc->version);
|
||||
error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out);
|
||||
@ -241,7 +241,7 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb
|
||||
|
||||
error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) Stream_Pointer(s));
|
||||
|
||||
data_out = stream_new(pos + 4);
|
||||
data_out = Stream_New(NULL, pos + 4);
|
||||
Stream_Write_UINT8(data_out, 0x10 | cbChId);
|
||||
Stream_SetPosition(s, 1);
|
||||
Stream_Copy(data_out, s, pos - 1);
|
||||
@ -346,7 +346,7 @@ static void drdynvc_process_receive(rdpSvcPlugin* plugin, wStream* s)
|
||||
break;
|
||||
}
|
||||
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
static void drdynvc_process_connect(rdpSvcPlugin* plugin)
|
||||
|
@ -398,7 +398,7 @@ int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelI
|
||||
|
||||
if (channel->dvc_data)
|
||||
{
|
||||
stream_free(channel->dvc_data);
|
||||
Stream_Free(channel->dvc_data, TRUE);
|
||||
channel->dvc_data = NULL;
|
||||
}
|
||||
|
||||
@ -422,9 +422,9 @@ int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, UI
|
||||
}
|
||||
|
||||
if (channel->dvc_data)
|
||||
stream_free(channel->dvc_data);
|
||||
Stream_Free(channel->dvc_data, TRUE);
|
||||
|
||||
channel->dvc_data = stream_new(length);
|
||||
channel->dvc_data = Stream_New(NULL, length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -448,7 +448,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C
|
||||
if (Stream_GetPosition(channel->dvc_data) + data_size > (UINT32) Stream_Capacity(channel->dvc_data))
|
||||
{
|
||||
DEBUG_WARN("data exceeding declared length!");
|
||||
stream_free(channel->dvc_data);
|
||||
Stream_Free(channel->dvc_data, TRUE);
|
||||
channel->dvc_data = NULL;
|
||||
return 1;
|
||||
}
|
||||
@ -459,7 +459,7 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C
|
||||
{
|
||||
error = channel->channel_callback->OnDataReceived(channel->channel_callback,
|
||||
Stream_Capacity(channel->dvc_data), Stream_Buffer(channel->dvc_data));
|
||||
stream_free(channel->dvc_data);
|
||||
Stream_Free(channel->dvc_data, TRUE);
|
||||
channel->dvc_data = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char*
|
||||
disk->device.Free = drive_free;
|
||||
|
||||
length = strlen(name);
|
||||
disk->device.data = stream_new(length + 1);
|
||||
disk->device.data = Stream_New(NULL, length + 1);
|
||||
|
||||
for (i = 0; i <= length; i++)
|
||||
Stream_Write_UINT8(disk->device.data, name[i] < 0 ? '_' : name[i]);
|
||||
|
@ -319,7 +319,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
||||
parallel->device.Free = parallel_free;
|
||||
|
||||
length = strlen(name);
|
||||
parallel->device.data = stream_new(length + 1);
|
||||
parallel->device.data = Stream_New(NULL, length + 1);
|
||||
|
||||
for (i = 0; i <= length; i++)
|
||||
Stream_Write_UINT8(parallel->device.data, name[i] < 0 ? '_' : name[i]);
|
||||
|
@ -259,7 +259,7 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
|
||||
DriverNameLen = ConvertToUnicode(CP_UTF8, 0, printer->driver, -1, &DriverName, 0) * 2;
|
||||
PrintNameLen = ConvertToUnicode(CP_UTF8, 0, printer->name, -1, &PrintName, 0) * 2;
|
||||
|
||||
printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen);
|
||||
printer_dev->device.data = Stream_New(NULL, 28 + DriverNameLen + PrintNameLen + CachedFieldsLen);
|
||||
|
||||
Stream_Write_UINT32(printer_dev->device.data, Flags);
|
||||
Stream_Write_UINT32(printer_dev->device.data, 0); /* CodePage, reserved */
|
||||
|
@ -43,7 +43,7 @@ void rail_send_channel_data(void* rail_object, void* data, size_t length)
|
||||
wStream* s = NULL;
|
||||
railPlugin* plugin = (railPlugin*) rail_object;
|
||||
|
||||
s = stream_new(length);
|
||||
s = Stream_New(NULL, length);
|
||||
Stream_Write(s, data, length);
|
||||
|
||||
svc_plugin_send((rdpSvcPlugin*) plugin, s);
|
||||
@ -89,7 +89,7 @@ static void rail_process_receive(rdpSvcPlugin* plugin, wStream* s)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) plugin;
|
||||
rail_order_recv(rail->rail_order, s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
static void rail_process_addin_args(rdpRailOrder* rail_order, rdpSettings* settings)
|
||||
|
@ -106,7 +106,7 @@ void rail_write_pdu_header(wStream* s, UINT16 orderType, UINT16 orderLength)
|
||||
wStream* rail_pdu_init(int length)
|
||||
{
|
||||
wStream* s;
|
||||
s = stream_new(length + RAIL_PDU_HEADER_LENGTH);
|
||||
s = Stream_New(NULL, length + RAIL_PDU_HEADER_LENGTH);
|
||||
Stream_Seek(s, RAIL_PDU_HEADER_LENGTH);
|
||||
return s;
|
||||
}
|
||||
@ -513,7 +513,7 @@ void rail_send_handshake_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_HANDSHAKE_ORDER_LENGTH);
|
||||
rail_write_handshake_order(s, &rail_order->handshake);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_HANDSHAKE);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_status_order(rdpRailOrder* rail_order)
|
||||
@ -522,7 +522,7 @@ void rail_send_client_status_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_CLIENT_STATUS_ORDER_LENGTH);
|
||||
rail_write_client_status_order(s, &rail_order->client_status);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_CLIENT_STATUS);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_exec_order(rdpRailOrder* rail_order)
|
||||
@ -538,7 +538,7 @@ void rail_send_client_exec_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_EXEC_ORDER_LENGTH);
|
||||
rail_write_client_exec_order(s, &rail_order->exec);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_EXEC);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_sysparam_order(rdpRailOrder* rail_order)
|
||||
@ -571,7 +571,7 @@ void rail_send_client_sysparam_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_SYSPARAM_ORDER_LENGTH + 8);
|
||||
rail_write_client_sysparam_order(s, &rail_order->sysparam);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_SYSPARAM);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_sysparams_order(rdpRailOrder* rail_order)
|
||||
@ -625,7 +625,7 @@ void rail_send_client_activate_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_ACTIVATE_ORDER_LENGTH);
|
||||
rail_write_client_activate_order(s, &rail_order->activate);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_ACTIVATE);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_sysmenu_order(rdpRailOrder* rail_order)
|
||||
@ -634,7 +634,7 @@ void rail_send_client_sysmenu_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_SYSMENU_ORDER_LENGTH);
|
||||
rail_write_client_sysmenu_order(s, &rail_order->sysmenu);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_SYSMENU);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_syscommand_order(rdpRailOrder* rail_order)
|
||||
@ -643,7 +643,7 @@ void rail_send_client_syscommand_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_SYSCOMMAND_ORDER_LENGTH);
|
||||
rail_write_client_syscommand_order(s, &rail_order->syscommand);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_SYSCOMMAND);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_notify_event_order(rdpRailOrder* rail_order)
|
||||
@ -652,7 +652,7 @@ void rail_send_client_notify_event_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_NOTIFY_EVENT_ORDER_LENGTH);
|
||||
rail_write_client_notify_event_order(s, &rail_order->notify_event);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_NOTIFY_EVENT);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_window_move_order(rdpRailOrder* rail_order)
|
||||
@ -661,7 +661,7 @@ void rail_send_client_window_move_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_WINDOW_MOVE_ORDER_LENGTH);
|
||||
rail_write_client_window_move_order(s, &rail_order->window_move);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_WINDOW_MOVE);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_get_appid_req_order(rdpRailOrder* rail_order)
|
||||
@ -670,7 +670,7 @@ void rail_send_client_get_appid_req_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_GET_APPID_REQ_ORDER_LENGTH);
|
||||
rail_write_client_get_appid_req_order(s, &rail_order->get_appid_req);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_GET_APPID_REQ);
|
||||
stream_free(s) ;
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
void rail_send_client_langbar_info_order(rdpRailOrder* rail_order)
|
||||
@ -679,7 +679,7 @@ void rail_send_client_langbar_info_order(rdpRailOrder* rail_order)
|
||||
s = rail_pdu_init(RAIL_LANGBAR_INFO_ORDER_LENGTH);
|
||||
rail_write_langbar_info_order(s, &rail_order->langbar_info);
|
||||
rail_send_pdu(rail_order, s, RAIL_ORDER_TYPE_LANGBAR_INFO);
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
rdpRailOrder* rail_order_new()
|
||||
|
@ -39,8 +39,8 @@ static void irp_free(IRP* irp)
|
||||
{
|
||||
DEBUG_SVC("DeviceId %d FileId %d CompletionId %d", irp->device->id, irp->FileId, irp->CompletionId);
|
||||
|
||||
stream_free(irp->input);
|
||||
stream_free(irp->output);
|
||||
Stream_Free(irp->input, TRUE);
|
||||
Stream_Free(irp->output, TRUE);
|
||||
|
||||
_aligned_free(irp);
|
||||
}
|
||||
@ -88,7 +88,7 @@ IRP* irp_new(DEVMAN* devman, wStream* data_in)
|
||||
Stream_Read_UINT32(data_in, irp->MinorFunction);
|
||||
irp->input = data_in;
|
||||
|
||||
irp->output = stream_new(256);
|
||||
irp->output = Stream_New(NULL, 256);
|
||||
Stream_Write_UINT16(irp->output, RDPDR_CTYP_CORE);
|
||||
Stream_Write_UINT16(irp->output, PAKID_CORE_DEVICE_IOCOMPLETION);
|
||||
Stream_Write_UINT32(irp->output, DeviceId);
|
||||
|
@ -172,7 +172,7 @@ void rdpdr_send_capability_response(rdpdrPlugin* rdpdr)
|
||||
{
|
||||
wStream* data_out;
|
||||
|
||||
data_out = stream_new(256);
|
||||
data_out = Stream_New(NULL, 256);
|
||||
|
||||
Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE);
|
||||
Stream_Write_UINT16(data_out, PAKID_CORE_CLIENT_CAPABILITY);
|
||||
|
@ -77,7 +77,7 @@ static void rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr)
|
||||
{
|
||||
wStream* data_out;
|
||||
|
||||
data_out = stream_new(12);
|
||||
data_out = Stream_New(NULL, 12);
|
||||
|
||||
Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE);
|
||||
Stream_Write_UINT16(data_out, PAKID_CORE_CLIENTID_CONFIRM);
|
||||
@ -100,7 +100,7 @@ static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
|
||||
|
||||
computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1, &computerNameW, 0) * 2;
|
||||
|
||||
data_out = stream_new(16 + computerNameLenW + 2);
|
||||
data_out = Stream_New(NULL, 16 + computerNameLenW + 2);
|
||||
|
||||
Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE);
|
||||
Stream_Write_UINT16(data_out, PAKID_CORE_CLIENT_NAME);
|
||||
@ -152,7 +152,7 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use
|
||||
DEVICE* device;
|
||||
LIST_ITEM* item;
|
||||
|
||||
data_out = stream_new(256);
|
||||
data_out = Stream_New(NULL, 256);
|
||||
|
||||
Stream_Write_UINT16(data_out, RDPDR_CTYP_CORE);
|
||||
Stream_Write_UINT16(data_out, PAKID_CORE_DEVICELIST_ANNOUNCE);
|
||||
@ -294,7 +294,7 @@ static void rdpdr_process_receive(rdpSvcPlugin* plugin, wStream* data_in)
|
||||
DEBUG_WARN("RDPDR component: 0x%02X packetID: 0x%02X", component, packetID);
|
||||
}
|
||||
|
||||
stream_free(data_in);
|
||||
Stream_Free(data_in, TRUE);
|
||||
}
|
||||
|
||||
static void rdpdr_process_event(rdpSvcPlugin* plugin, wMessage* event)
|
||||
|
@ -126,7 +126,7 @@ void rdpsnd_send_quality_mode_pdu(rdpsndPlugin* rdpsnd)
|
||||
{
|
||||
wStream* pdu;
|
||||
|
||||
pdu = stream_new(8);
|
||||
pdu = Stream_New(NULL, 8);
|
||||
Stream_Write_UINT8(pdu, SNDC_QUALITYMODE); /* msgType */
|
||||
Stream_Write_UINT8(pdu, 0); /* bPad */
|
||||
Stream_Write_UINT16(pdu, 4); /* BodySize */
|
||||
@ -217,7 +217,7 @@ void rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd)
|
||||
for (index = 0; index < (int) wNumberOfFormats; index++)
|
||||
length += (18 + rdpsnd->ClientFormats[index].cbSize);
|
||||
|
||||
pdu = stream_new(length);
|
||||
pdu = Stream_New(NULL, length);
|
||||
|
||||
Stream_Write_UINT8(pdu, SNDC_FORMATS); /* msgType */
|
||||
Stream_Write_UINT8(pdu, 0); /* bPad */
|
||||
@ -302,7 +302,7 @@ void rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, U
|
||||
{
|
||||
wStream* pdu;
|
||||
|
||||
pdu = stream_new(8);
|
||||
pdu = Stream_New(NULL, 8);
|
||||
Stream_Write_UINT8(pdu, SNDC_TRAINING); /* msgType */
|
||||
Stream_Write_UINT8(pdu, 0); /* bPad */
|
||||
Stream_Write_UINT16(pdu, 4); /* BodySize */
|
||||
@ -367,7 +367,7 @@ void rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, BYTE
|
||||
{
|
||||
wStream* pdu;
|
||||
|
||||
pdu = stream_new(8);
|
||||
pdu = Stream_New(NULL, 8);
|
||||
Stream_Write_UINT8(pdu, SNDC_WAVECONFIRM);
|
||||
Stream_Write_UINT8(pdu, 0);
|
||||
Stream_Write_UINT16(pdu, 4);
|
||||
@ -476,7 +476,7 @@ static void rdpsnd_recv_pdu(rdpSvcPlugin* plugin, wStream* s)
|
||||
if (rdpsnd->expectingWave)
|
||||
{
|
||||
rdpsnd_recv_wave_pdu(rdpsnd, s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -513,7 +513,7 @@ static void rdpsnd_recv_pdu(rdpSvcPlugin* plugin, wStream* s)
|
||||
break;
|
||||
}
|
||||
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd, rdpsndDevicePlugin* device)
|
||||
|
@ -203,7 +203,7 @@ static void* rdpsnd_server_thread_func(void* arg)
|
||||
events[1] = CreateWaitObjectEvent(NULL, TRUE, FALSE, fd);
|
||||
}
|
||||
|
||||
s = stream_new(4096);
|
||||
s = Stream_New(NULL, 4096);
|
||||
|
||||
rdpsnd_server_send_formats(rdpsnd, s);
|
||||
|
||||
@ -256,7 +256,7 @@ static void* rdpsnd_server_thread_func(void* arg)
|
||||
}
|
||||
}
|
||||
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -269,7 +269,7 @@ static BOOL rdpsnd_server_initialize(rdpsnd_server_context* context)
|
||||
|
||||
if (rdpsnd->rdpsnd_channel != NULL)
|
||||
{
|
||||
rdpsnd->rdpsnd_pdu = stream_new(4096);
|
||||
rdpsnd->rdpsnd_pdu = Stream_New(NULL, 4096);
|
||||
|
||||
rdpsnd->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
@ -545,7 +545,7 @@ void rdpsnd_server_context_free(rdpsnd_server_context* context)
|
||||
WTSVirtualChannelClose(rdpsnd->rdpsnd_channel);
|
||||
|
||||
if (rdpsnd->rdpsnd_pdu)
|
||||
stream_free(rdpsnd->rdpsnd_pdu);
|
||||
Stream_Free(rdpsnd->rdpsnd_pdu, TRUE);
|
||||
|
||||
if (rdpsnd->out_buffer)
|
||||
free(rdpsnd->out_buffer);
|
||||
|
@ -69,7 +69,7 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in)
|
||||
|
||||
if (bytes > 0)
|
||||
{
|
||||
data_out = stream_new(bytes);
|
||||
data_out = Stream_New(NULL, bytes);
|
||||
Stream_Copy(data_out, data_in, bytes);
|
||||
/* svc_plugin_send takes ownership of data_out, that is why
|
||||
we do not free it */
|
||||
@ -80,7 +80,7 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in)
|
||||
svc_plugin_send(plugin, data_out);
|
||||
}
|
||||
|
||||
stream_free(data_in);
|
||||
Stream_Free(data_in, TRUE);
|
||||
}
|
||||
|
||||
static void sample_process_connect(rdpSvcPlugin* plugin)
|
||||
|
@ -703,7 +703,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
||||
serial->device.Free = serial_free;
|
||||
|
||||
len = strlen(name);
|
||||
serial->device.data = stream_new(len + 1);
|
||||
serial->device.data = Stream_New(NULL, len + 1);
|
||||
|
||||
for (i = 0; i <= len; i++)
|
||||
Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]);
|
||||
|
@ -564,7 +564,7 @@ void* WTSVirtualChannelOpenEx(
|
||||
channel->vcm = vcm;
|
||||
channel->client = client;
|
||||
channel->channel_type = RDP_PEER_CHANNEL_TYPE_DVC;
|
||||
channel->receive_data = stream_new(client->settings->VirtualChannelChunkSize);
|
||||
channel->receive_data = Stream_New(NULL, client->settings->VirtualChannelChunkSize);
|
||||
channel->receive_event = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
channel->receive_queue = list_new();
|
||||
channel->mutex = CreateMutex(NULL, FALSE, NULL);
|
||||
@ -574,10 +574,10 @@ void* WTSVirtualChannelOpenEx(
|
||||
list_enqueue(vcm->dvc_channel_list, channel);
|
||||
ReleaseMutex(vcm->mutex);
|
||||
|
||||
s = stream_new(64);
|
||||
s = Stream_New(NULL, 64);
|
||||
wts_write_drdynvc_create_request(s, channel->channel_id, pVirtualName);
|
||||
WTSVirtualChannelWrite(vcm->drdynvc_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL);
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
DEBUG_DVC("ChannelId %d.%s (total %d)", channel->channel_id, pVirtualName, list_size(vcm->dvc_channel_list));
|
||||
}
|
||||
@ -612,7 +612,7 @@ void* WTSVirtualChannelOpenEx(
|
||||
channel->channel_id = client->settings->ChannelDefArray[i].ChannelId;
|
||||
channel->index = i;
|
||||
channel->channel_type = RDP_PEER_CHANNEL_TYPE_SVC;
|
||||
channel->receive_data = stream_new(client->settings->VirtualChannelChunkSize);
|
||||
channel->receive_data = Stream_New(NULL, client->settings->VirtualChannelChunkSize);
|
||||
channel->receive_event = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
channel->receive_queue = list_new();
|
||||
channel->mutex = CreateMutex(NULL, FALSE, NULL);
|
||||
@ -773,7 +773,6 @@ BOOL WTSVirtualChannelWrite(
|
||||
}
|
||||
else
|
||||
{
|
||||
s = stream_new(0);
|
||||
first = TRUE;
|
||||
|
||||
while (Length > 0)
|
||||
@ -781,8 +780,8 @@ BOOL WTSVirtualChannelWrite(
|
||||
item = (wts_data_item*) malloc(sizeof(wts_data_item));
|
||||
ZeroMemory(item, sizeof(wts_data_item));
|
||||
|
||||
item->buffer = malloc(channel->client->settings->VirtualChannelChunkSize);
|
||||
stream_attach(s, item->buffer, channel->client->settings->VirtualChannelChunkSize);
|
||||
s = Stream_New(NULL, channel->client->settings->VirtualChannelChunkSize);
|
||||
item->buffer = Stream_Buffer(s);
|
||||
|
||||
Stream_Seek_UINT8(s);
|
||||
cbChId = wts_write_variable_uint(s, channel->channel_id);
|
||||
@ -805,18 +804,18 @@ BOOL WTSVirtualChannelWrite(
|
||||
|
||||
Stream_Write(s, Buffer, written);
|
||||
item->length = Stream_GetPosition(s);
|
||||
stream_detach(s);
|
||||
Stream_Free(s, FALSE);
|
||||
|
||||
Length -= written;
|
||||
Buffer += written;
|
||||
|
||||
wts_queue_send_item(channel->vcm->drdynvc_channel, item);
|
||||
}
|
||||
|
||||
stream_free(s);
|
||||
}
|
||||
|
||||
if (pBytesWritten != NULL)
|
||||
*pBytesWritten = Length;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -845,15 +844,15 @@ BOOL WTSVirtualChannelClose(
|
||||
|
||||
if (channel->dvc_open_state == DVC_OPEN_STATE_SUCCEEDED)
|
||||
{
|
||||
s = stream_new(8);
|
||||
s = Stream_New(NULL, 8);
|
||||
wts_write_drdynvc_header(s, CLOSE_REQUEST_PDU, channel->channel_id);
|
||||
WTSVirtualChannelWrite(vcm->drdynvc_channel, Stream_Buffer(s), Stream_GetPosition(s), NULL);
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (channel->receive_data)
|
||||
stream_free(channel->receive_data);
|
||||
Stream_Free(channel->receive_data, TRUE);
|
||||
|
||||
if (channel->receive_event)
|
||||
CloseHandle(channel->receive_event);
|
||||
|
@ -325,7 +325,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
||||
smartcard->device.Free = smartcard_free;
|
||||
|
||||
length = strlen(smartcard->device.name);
|
||||
smartcard->device.data = stream_new(length + 1);
|
||||
smartcard->device.data = Stream_New(NULL, length + 1);
|
||||
|
||||
for (i = 0; i <= length; i++)
|
||||
Stream_Write_UINT8(smartcard->device.data, name[i] < 0 ? '_' : name[i]);
|
||||
|
@ -81,7 +81,7 @@ void tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
int status;
|
||||
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*) pChannelCallback;
|
||||
|
||||
s = stream_new(32);
|
||||
s = Stream_New(NULL, 32);
|
||||
Stream_Write_UINT32(s, TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY);
|
||||
Stream_Write_UINT32(s, message_id);
|
||||
Stream_Write_UINT32(s, PLAYBACK_ACK); /* FunctionId */
|
||||
@ -97,7 +97,7 @@ void tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
DEBUG_WARN("response error %d", status);
|
||||
}
|
||||
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
BOOL tsmf_push_event(IWTSVirtualChannelCallback* pChannelCallback, wMessage* event)
|
||||
@ -136,9 +136,9 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
DEBUG_WARN("invalid size. cbSize=%d", cbSize);
|
||||
return 1;
|
||||
}
|
||||
input = stream_new(0);
|
||||
stream_attach(input, (BYTE*) pBuffer, cbSize);
|
||||
output = stream_new(256);
|
||||
|
||||
input = Stream_New((BYTE*) pBuffer, cbSize);
|
||||
output = Stream_New(NULL, 256);
|
||||
Stream_Seek(output, 8);
|
||||
|
||||
Stream_Read_UINT32(input, InterfaceId);
|
||||
@ -282,8 +282,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
break;
|
||||
}
|
||||
|
||||
stream_detach(input);
|
||||
stream_free(input);
|
||||
Stream_Free(input, FALSE);
|
||||
input = NULL;
|
||||
ifman.input = NULL;
|
||||
|
||||
@ -330,7 +329,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
|
||||
}
|
||||
}
|
||||
|
||||
stream_free(output);
|
||||
Stream_Free(output, TRUE);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -928,18 +928,16 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size)
|
||||
return;
|
||||
}
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, data, size);
|
||||
s = Stream_New(data, size);
|
||||
Stream_Seek(s, 14);
|
||||
Stream_Read_UINT16(s, bpp);
|
||||
Stream_Read_UINT32(s, ncolors);
|
||||
offset = 14 + 40 + (bpp <= 8 ? (ncolors == 0 ? (1 << bpp) : ncolors) * 4 : 0);
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, FALSE);
|
||||
|
||||
DEBUG_X11_CLIPRDR("offset=%d bpp=%d ncolors=%d", offset, bpp, ncolors);
|
||||
|
||||
s = stream_new(14 + size);
|
||||
s = Stream_New(NULL, 14 + size);
|
||||
Stream_Write_UINT8(s, 'B');
|
||||
Stream_Write_UINT8(s, 'M');
|
||||
Stream_Write_UINT32(s, 14 + size);
|
||||
@ -949,8 +947,7 @@ static void xf_cliprdr_process_dib(clipboardContext* cb, BYTE* data, int size)
|
||||
|
||||
cb->data = Stream_Buffer(s);
|
||||
cb->data_length = Stream_GetPosition(s);
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, FALSE);
|
||||
}
|
||||
|
||||
static void xf_cliprdr_process_html(clipboardContext* cb, BYTE* data, int size)
|
||||
|
@ -111,5 +111,5 @@ void test_mcs_write_connect_initial(void)
|
||||
|
||||
ASSERT_STREAM(s, (BYTE*) mcs_connect_initial_expected, sizeof(mcs_connect_initial_expected));
|
||||
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ void test_decode(void)
|
||||
sizeof(cr_data), test_quantization_values,
|
||||
decode_buffer);
|
||||
rfx_context_free(context);
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
dump_ppm_image(decode_buffer);
|
||||
}
|
||||
@ -410,7 +410,7 @@ void test_message(void)
|
||||
}
|
||||
}
|
||||
rfx_message_free(context, message);
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
rfx_context_free(context);
|
||||
|
@ -329,14 +329,12 @@ void nsc_process_message(NSC_CONTEXT* context, UINT16 bpp,
|
||||
{
|
||||
wStream* s;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, data, length);
|
||||
s = Stream_New(data, length);
|
||||
context->bpp = bpp;
|
||||
context->width = width;
|
||||
context->height = height;
|
||||
nsc_context_initialize(context, s);
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, FALSE);
|
||||
|
||||
/* RLE decode */
|
||||
PROFILER_ENTER(context->priv->prof_nsc_rle_decompress_data);
|
||||
|
@ -758,8 +758,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length
|
||||
message = (RFX_MESSAGE*) malloc(sizeof(RFX_MESSAGE));
|
||||
ZeroMemory(message, sizeof(RFX_MESSAGE));
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, data, length);
|
||||
s = Stream_New(data, length);
|
||||
|
||||
while (Stream_GetRemainingLength(s) > 6)
|
||||
{
|
||||
@ -789,7 +788,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length
|
||||
/* RFX_CODEC_CHANNELT */
|
||||
/* codecId (1 byte) must be set to 0x01 */
|
||||
/* channelId (1 byte) must be set to 0x00 */
|
||||
if (!stream_skip(s, 2))
|
||||
if (!Stream_SafeSeek(s, 2))
|
||||
{
|
||||
DEBUG_WARN("rfx_process_message: unable to skip RFX_CODEC_CHANNELT");
|
||||
break;
|
||||
@ -838,8 +837,7 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length
|
||||
Stream_SetPosition(s, pos);
|
||||
}
|
||||
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, FALSE);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
@ -3308,7 +3308,7 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s)
|
||||
Stream_Read_UINT16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */
|
||||
Stream_Read_UINT16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */
|
||||
|
||||
if (!stream_skip(s, lengthSourceDescriptor) || Stream_GetRemainingLength(s) < 4) /* sourceDescriptor */
|
||||
if (!Stream_SafeSeek(s, lengthSourceDescriptor) || Stream_GetRemainingLength(s) < 4) /* sourceDescriptor */
|
||||
return FALSE;
|
||||
|
||||
Stream_Read_UINT16(s, numberCapabilities); /* numberCapabilities (2 bytes) */
|
||||
|
@ -160,110 +160,115 @@ BOOL certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info)
|
||||
int exponent_length;
|
||||
int error = 0;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, cert->data, cert->length);
|
||||
s = Stream_New(cert->data, cert->length);
|
||||
info->Modulus = 0;
|
||||
|
||||
if(!ber_read_sequence_tag(s, &length)) /* Certificate (SEQUENCE) */
|
||||
if (!ber_read_sequence_tag(s, &length)) /* Certificate (SEQUENCE) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
if(!ber_read_sequence_tag(s, &length)) /* TBSCertificate (SEQUENCE) */
|
||||
if (!ber_read_sequence_tag(s, &length)) /* TBSCertificate (SEQUENCE) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
if(!ber_read_contextual_tag(s, 0, &length, TRUE)) /* Explicit Contextual Tag [0] */
|
||||
if (!ber_read_contextual_tag(s, 0, &length, TRUE)) /* Explicit Contextual Tag [0] */
|
||||
goto error1;
|
||||
error++;
|
||||
if(!ber_read_integer(s, &version)) /* version (INTEGER) */
|
||||
if (!ber_read_integer(s, &version)) /* version (INTEGER) */
|
||||
goto error1;
|
||||
error++;
|
||||
version++;
|
||||
|
||||
/* serialNumber */
|
||||
if(!ber_read_integer(s, NULL)) /* CertificateSerialNumber (INTEGER) */
|
||||
if (!ber_read_integer(s, NULL)) /* CertificateSerialNumber (INTEGER) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
/* signature */
|
||||
if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* AlgorithmIdentifier (SEQUENCE) */
|
||||
if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* AlgorithmIdentifier (SEQUENCE) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
/* issuer */
|
||||
if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* Name (SEQUENCE) */
|
||||
if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* Name (SEQUENCE) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
/* validity */
|
||||
if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* Validity (SEQUENCE) */
|
||||
if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* Validity (SEQUENCE) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
/* subject */
|
||||
if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* Name (SEQUENCE) */
|
||||
if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* Name (SEQUENCE) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
/* subjectPublicKeyInfo */
|
||||
if(!ber_read_sequence_tag(s, &length)) /* SubjectPublicKeyInfo (SEQUENCE) */
|
||||
if (!ber_read_sequence_tag(s, &length)) /* SubjectPublicKeyInfo (SEQUENCE) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
/* subjectPublicKeyInfo::AlgorithmIdentifier */
|
||||
if(!ber_read_sequence_tag(s, &length) || !stream_skip(s, length)) /* AlgorithmIdentifier (SEQUENCE) */
|
||||
if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* AlgorithmIdentifier (SEQUENCE) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
/* subjectPublicKeyInfo::subjectPublicKey */
|
||||
if(!ber_read_bit_string(s, &length, &padding)) /* BIT_STRING */
|
||||
if (!ber_read_bit_string(s, &length, &padding)) /* BIT_STRING */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
/* RSAPublicKey (SEQUENCE) */
|
||||
if(!ber_read_sequence_tag(s, &length)) /* SEQUENCE */
|
||||
if (!ber_read_sequence_tag(s, &length)) /* SEQUENCE */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
if(!ber_read_integer_length(s, &modulus_length)) /* modulus (INTEGER) */
|
||||
if (!ber_read_integer_length(s, &modulus_length)) /* modulus (INTEGER) */
|
||||
goto error1;
|
||||
error++;
|
||||
|
||||
/* skip zero padding, if any */
|
||||
do
|
||||
{
|
||||
if(Stream_GetRemainingLength(s) < 1)
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
goto error1;
|
||||
|
||||
Stream_Peek_UINT8(s, padding);
|
||||
|
||||
if (padding == 0)
|
||||
{
|
||||
if(!stream_skip(s, 1))
|
||||
if (!Stream_SafeSeek(s, 1))
|
||||
goto error1;
|
||||
|
||||
modulus_length--;
|
||||
}
|
||||
}
|
||||
while (padding == 0);
|
||||
|
||||
error++;
|
||||
|
||||
if(Stream_GetRemainingLength(s) < modulus_length)
|
||||
if (Stream_GetRemainingLength(s) < modulus_length)
|
||||
goto error1;
|
||||
|
||||
info->ModulusLength = modulus_length;
|
||||
info->Modulus = (BYTE*) malloc(info->ModulusLength);
|
||||
Stream_Read(s, info->Modulus, info->ModulusLength);
|
||||
error++;
|
||||
|
||||
if(!ber_read_integer_length(s, &exponent_length)) /* publicExponent (INTEGER) */
|
||||
if (!ber_read_integer_length(s, &exponent_length)) /* publicExponent (INTEGER) */
|
||||
goto error2;
|
||||
|
||||
error++;
|
||||
if(Stream_GetRemainingLength(s) < exponent_length || exponent_length > 4)
|
||||
|
||||
if (Stream_GetRemainingLength(s) < exponent_length || exponent_length > 4)
|
||||
goto error2;
|
||||
|
||||
Stream_Read(s, &info->exponent[4 - exponent_length], exponent_length);
|
||||
crypto_reverse(info->Modulus, info->ModulusLength);
|
||||
crypto_reverse(info->exponent, 4);
|
||||
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, FALSE);
|
||||
return TRUE;
|
||||
|
||||
error2:
|
||||
@ -271,8 +276,7 @@ error2:
|
||||
info->Modulus = 0;
|
||||
error1:
|
||||
fprintf(stderr, "error reading when reading certificate: part=%s error=%d\n", certificate_read_errors[error], error);
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -325,7 +329,7 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w
|
||||
UINT32 datalen;
|
||||
UINT32 modlen;
|
||||
|
||||
if(Stream_GetRemainingLength(s) < 20)
|
||||
if (Stream_GetRemainingLength(s) < 20)
|
||||
return FALSE;
|
||||
Stream_Read(s, magic, 4);
|
||||
|
||||
@ -341,7 +345,7 @@ static BOOL certificate_process_server_public_key(rdpCertificate* certificate, w
|
||||
Stream_Read(s, certificate->cert_info.exponent, 4);
|
||||
modlen = keylen - 8;
|
||||
|
||||
if(Stream_GetRemainingLength(s) < modlen + 8) // count padding
|
||||
if (Stream_GetRemainingLength(s) < modlen + 8) // count padding
|
||||
return FALSE;
|
||||
certificate->cert_info.ModulusLength = modlen;
|
||||
certificate->cert_info.Modulus = malloc(certificate->cert_info.ModulusLength);
|
||||
@ -425,7 +429,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate
|
||||
BYTE* sigdata;
|
||||
int sigdatalen;
|
||||
|
||||
if(Stream_GetRemainingLength(s) < 12)
|
||||
if (Stream_GetRemainingLength(s) < 12)
|
||||
return FALSE;
|
||||
|
||||
/* -4, because we need to include dwVersion */
|
||||
@ -448,7 +452,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate
|
||||
}
|
||||
|
||||
Stream_Read_UINT16(s, wPublicKeyBlobLen);
|
||||
if(Stream_GetRemainingLength(s) < wPublicKeyBlobLen)
|
||||
if (Stream_GetRemainingLength(s) < wPublicKeyBlobLen)
|
||||
return FALSE;
|
||||
|
||||
if (!certificate_process_server_public_key(certificate, s, wPublicKeyBlobLen))
|
||||
@ -457,7 +461,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
sigdatalen = Stream_Pointer(s) - sigdata;
|
||||
@ -470,7 +474,7 @@ BOOL certificate_read_server_proprietary_certificate(rdpCertificate* certificate
|
||||
}
|
||||
|
||||
Stream_Read_UINT16(s, wSignatureBlobLen);
|
||||
if(Stream_GetRemainingLength(s) < wSignatureBlobLen)
|
||||
if (Stream_GetRemainingLength(s) < wSignatureBlobLen)
|
||||
return FALSE;
|
||||
|
||||
if (wSignatureBlobLen != 72)
|
||||
@ -503,7 +507,7 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate,
|
||||
|
||||
DEBUG_CERTIFICATE("Server X.509 Certificate Chain");
|
||||
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
Stream_Read_UINT32(s, numCertBlobs); /* numCertBlobs */
|
||||
|
||||
@ -511,10 +515,12 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate,
|
||||
|
||||
for (i = 0; i < (int) numCertBlobs; i++)
|
||||
{
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
|
||||
Stream_Read_UINT32(s, certLength);
|
||||
if(Stream_GetRemainingLength(s) < certLength)
|
||||
|
||||
if (Stream_GetRemainingLength(s) < certLength)
|
||||
return FALSE;
|
||||
|
||||
DEBUG_CERTIFICATE("\nX.509 Certificate #%d, length:%d", i + 1, certLength);
|
||||
@ -571,8 +577,7 @@ int certificate_read_server_certificate(rdpCertificate* certificate, BYTE* serve
|
||||
if (length < 4)
|
||||
return -1;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, server_cert, length);
|
||||
s = Stream_New(server_cert, length);
|
||||
|
||||
Stream_Read_UINT32(s, dwVersion); /* dwVersion (4 bytes) */
|
||||
|
||||
@ -592,7 +597,7 @@ int certificate_read_server_certificate(rdpCertificate* certificate, BYTE* serve
|
||||
break;
|
||||
}
|
||||
|
||||
free(s);
|
||||
Stream_Free(s, FALSE);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ static BOOL fastpath_recv_update_synchronize(rdpFastPath* fastpath, wStream* s)
|
||||
{
|
||||
/* server 2008 can send invalid synchronize packet with missing padding,
|
||||
so don't return FALSE even if the packet is invalid */
|
||||
stream_skip(s, 2); /* size (2 bytes), MUST be set to zero */
|
||||
Stream_SafeSeek(s, 2); /* size (2 bytes), MUST be set to zero */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -813,13 +813,13 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
|
||||
result = TRUE;
|
||||
rdp = fastpath->rdp;
|
||||
update = comp_update = ls = NULL;
|
||||
try_comp = rdp->settings->CompressionEnabled;
|
||||
|
||||
sec_bytes = fastpath_get_sec_bytes(rdp);
|
||||
maxLength = FASTPATH_MAX_PACKET_SIZE - (6 + sec_bytes);
|
||||
totalLength = Stream_GetPosition(s) - (6 + sec_bytes);
|
||||
Stream_SetPosition(s, 0);
|
||||
update = stream_new(0);
|
||||
try_comp = rdp->settings->CompressionEnabled;
|
||||
comp_update = stream_new(0);
|
||||
|
||||
for (fragment = 0; (totalLength > 0) || (fragment == 0); fragment++)
|
||||
{
|
||||
@ -842,7 +842,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
comp_flags = FASTPATH_OUTPUT_COMPRESSION_USED;
|
||||
header_bytes = 7 + sec_bytes;
|
||||
bm = (BYTE*) (rdp->mppc_enc->outputBuffer - header_bytes);
|
||||
stream_attach(comp_update, bm, pdu_data_bytes + header_bytes);
|
||||
comp_update = Stream_New(bm, pdu_data_bytes + header_bytes);
|
||||
ls = comp_update;
|
||||
}
|
||||
}
|
||||
@ -888,7 +888,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
|
||||
Stream_Write_UINT16(ls, pdu_data_bytes);
|
||||
|
||||
stream_attach(update, bm, pduLength);
|
||||
update = Stream_New(bm, pduLength);
|
||||
Stream_Seek(update, pduLength);
|
||||
|
||||
if (sec_bytes > 0)
|
||||
@ -915,10 +915,8 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
Stream_SetPointer(s, holdp + dlen);
|
||||
}
|
||||
|
||||
stream_detach(update);
|
||||
stream_detach(comp_update);
|
||||
stream_free(update);
|
||||
stream_free(comp_update);
|
||||
Stream_Free(update, FALSE);
|
||||
Stream_Free(comp_update, FALSE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ BOOL freerdp_connect(freerdp* instance)
|
||||
rdpUpdate* update;
|
||||
pcap_record record;
|
||||
|
||||
s = stream_new(1024);
|
||||
s = Stream_New(NULL, 1024);
|
||||
instance->update->pcap_rfx = pcap_open(instance->settings->PlayRemoteFxFile, FALSE);
|
||||
|
||||
if (instance->update->pcap_rfx)
|
||||
|
@ -1140,7 +1140,7 @@ BOOL gcc_read_server_network_data(wStream* s, rdpSettings* settings)
|
||||
}
|
||||
|
||||
if (channelCount % 2 == 1)
|
||||
return stream_skip(s, 2); /* padding */
|
||||
return Stream_SafeSeek(s, 2); /* padding */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters)
|
||||
int length;
|
||||
wStream* tmps;
|
||||
|
||||
tmps = stream_new(Stream_Capacity(s));
|
||||
tmps = Stream_New(NULL, Stream_Capacity(s));
|
||||
ber_write_integer(tmps, domainParameters->maxChannelIds);
|
||||
ber_write_integer(tmps, domainParameters->maxUserIds);
|
||||
ber_write_integer(tmps, domainParameters->maxTokenIds);
|
||||
@ -297,7 +297,7 @@ void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters)
|
||||
length = Stream_GetPosition(tmps);
|
||||
ber_write_sequence_tag(s, length);
|
||||
Stream_Write(s, Stream_Buffer(tmps), length);
|
||||
stream_free(tmps);
|
||||
Stream_Free(tmps, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -388,7 +388,7 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data)
|
||||
int length;
|
||||
wStream* tmps;
|
||||
|
||||
tmps = stream_new(Stream_Capacity(s));
|
||||
tmps = Stream_New(NULL, Stream_Capacity(s));
|
||||
|
||||
/* callingDomainSelector (OCTET_STRING) */
|
||||
ber_write_octet_string(tmps, callingDomainSelector, sizeof(callingDomainSelector));
|
||||
@ -415,7 +415,7 @@ void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data)
|
||||
/* Connect-Initial (APPLICATION 101, IMPLICIT SEQUENCE) */
|
||||
ber_write_application_tag(s, MCS_TYPE_CONNECT_INITIAL, length);
|
||||
Stream_Write(s, Stream_Buffer(tmps), length);
|
||||
stream_free(tmps);
|
||||
Stream_Free(tmps, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -431,7 +431,7 @@ void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data)
|
||||
int length;
|
||||
wStream* tmps;
|
||||
|
||||
tmps = stream_new(Stream_Capacity(s));
|
||||
tmps = Stream_New(NULL, Stream_Capacity(s));
|
||||
ber_write_enumerated(tmps, 0, MCS_Result_enum_length);
|
||||
ber_write_integer(tmps, 0); /* calledConnectId */
|
||||
mcs->domainParameters = mcs->targetParameters;
|
||||
@ -442,7 +442,7 @@ void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data)
|
||||
length = Stream_GetPosition(tmps);
|
||||
ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length);
|
||||
Stream_Write(s, Stream_Buffer(tmps), length);
|
||||
stream_free(tmps);
|
||||
Stream_Free(tmps, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -460,10 +460,10 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs)
|
||||
wStream* client_data;
|
||||
int status;
|
||||
|
||||
client_data = stream_new(512);
|
||||
client_data = Stream_New(NULL, 512);
|
||||
gcc_write_client_data_blocks(client_data, mcs->transport->settings);
|
||||
|
||||
gcc_CCrq = stream_new(512);
|
||||
gcc_CCrq = Stream_New(NULL, 512);
|
||||
gcc_write_conference_create_request(gcc_CCrq, client_data);
|
||||
length = Stream_GetPosition(gcc_CCrq) + 7;
|
||||
|
||||
@ -482,8 +482,8 @@ BOOL mcs_send_connect_initial(rdpMcs* mcs)
|
||||
|
||||
status = transport_write(mcs->transport, s);
|
||||
|
||||
stream_free(gcc_CCrq);
|
||||
stream_free(client_data);
|
||||
Stream_Free(gcc_CCrq, TRUE);
|
||||
Stream_Free(client_data, TRUE);
|
||||
|
||||
return (status < 0 ? FALSE : TRUE);
|
||||
}
|
||||
@ -539,10 +539,10 @@ BOOL mcs_send_connect_response(rdpMcs* mcs)
|
||||
wStream* gcc_CCrsp;
|
||||
wStream* server_data;
|
||||
|
||||
server_data = stream_new(512);
|
||||
server_data = Stream_New(NULL, 512);
|
||||
gcc_write_server_data_blocks(server_data, mcs->transport->settings);
|
||||
|
||||
gcc_CCrsp = stream_new(512);
|
||||
gcc_CCrsp = Stream_New(NULL, 512);
|
||||
gcc_write_conference_create_response(gcc_CCrsp, server_data);
|
||||
length = Stream_GetPosition(gcc_CCrsp) + 7;
|
||||
|
||||
@ -561,8 +561,8 @@ BOOL mcs_send_connect_response(rdpMcs* mcs)
|
||||
|
||||
ret = transport_write(mcs->transport, s);
|
||||
|
||||
stream_free(gcc_CCrsp);
|
||||
stream_free(server_data);
|
||||
Stream_Free(gcc_CCrsp, TRUE);
|
||||
Stream_Free(server_data, TRUE);
|
||||
|
||||
return (ret < 0) ? FALSE : TRUE;
|
||||
}
|
||||
|
@ -891,8 +891,7 @@ void credssp_read_ts_credentials(rdpCredssp* credssp, PSecBuffer ts_credentials)
|
||||
int length;
|
||||
int ts_password_creds_length;
|
||||
|
||||
s = stream_new(0);
|
||||
stream_attach(s, ts_credentials->pvBuffer, ts_credentials->cbBuffer);
|
||||
s = Stream_New(ts_credentials->pvBuffer, ts_credentials->cbBuffer);
|
||||
|
||||
/* TSCredentials (SEQUENCE) */
|
||||
ber_read_sequence_tag(s, &length);
|
||||
@ -907,8 +906,7 @@ void credssp_read_ts_credentials(rdpCredssp* credssp, PSecBuffer ts_credentials)
|
||||
|
||||
credssp_read_ts_password_creds(credssp, s);
|
||||
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, FALSE);
|
||||
}
|
||||
|
||||
void credssp_write_ts_credentials(rdpCredssp* credssp, wStream* s)
|
||||
@ -945,14 +943,13 @@ void credssp_encode_ts_credentials(rdpCredssp* credssp)
|
||||
wStream* s;
|
||||
int length;
|
||||
|
||||
s = stream_new(0);
|
||||
length = credssp_skip_ts_credentials(credssp);
|
||||
sspi_SecBufferAlloc(&credssp->ts_credentials, length);
|
||||
stream_attach(s, credssp->ts_credentials.pvBuffer, length);
|
||||
|
||||
s = Stream_New(credssp->ts_credentials.pvBuffer, length);
|
||||
credssp_write_ts_credentials(credssp, s);
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
|
||||
Stream_Free(s, FALSE);
|
||||
}
|
||||
|
||||
SECURITY_STATUS credssp_encrypt_ts_credentials(rdpCredssp* credssp)
|
||||
@ -1091,7 +1088,7 @@ void credssp_send(rdpCredssp* credssp)
|
||||
length = nego_tokens_length + pub_key_auth_length + auth_info_length;
|
||||
ts_request_length = credssp_skip_ts_request(length);
|
||||
|
||||
s = stream_new(ts_request_length);
|
||||
s = Stream_New(NULL, ts_request_length);
|
||||
|
||||
/* TSRequest */
|
||||
length = der_get_content_length(ts_request_length);
|
||||
@ -1129,7 +1126,7 @@ void credssp_send(rdpCredssp* credssp)
|
||||
}
|
||||
|
||||
transport_write(credssp->transport, s);
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1145,7 +1142,7 @@ int credssp_recv(rdpCredssp* credssp)
|
||||
int status;
|
||||
UINT32 version;
|
||||
|
||||
s = stream_new(4096);
|
||||
s = Stream_New(NULL, 4096);
|
||||
|
||||
status = transport_read(credssp->transport, s);
|
||||
Stream_Length(s) = status;
|
||||
@ -1153,7 +1150,7 @@ int credssp_recv(rdpCredssp* credssp)
|
||||
if (status < 0)
|
||||
{
|
||||
fprintf(stderr, "credssp_recv() error: %d\n", status);
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1199,7 +1196,7 @@ int credssp_recv(rdpCredssp* credssp)
|
||||
credssp->pubKeyAuth.cbBuffer = length;
|
||||
}
|
||||
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -776,7 +776,7 @@ static INLINE BOOL update_read_delta_points(wStream* s, DELTA_POINT* points, int
|
||||
return FALSE; \
|
||||
}\
|
||||
Stream_Read_UINT16(s, TARGET_LEN); \
|
||||
if (!stream_skip(s, TARGET_LEN)) { \
|
||||
if (!Stream_SafeSeek(s, TARGET_LEN)) { \
|
||||
fprintf(stderr, "%s: error skipping %d bytes\n", __FUNCTION__, TARGET_LEN); \
|
||||
return FALSE; \
|
||||
} \
|
||||
@ -1389,7 +1389,7 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_
|
||||
memcpy(fast_glyph->data, s->pointer, fast_glyph->cbData);
|
||||
phold = s->pointer;
|
||||
|
||||
if (!stream_skip(s, 1))
|
||||
if (!Stream_SafeSeek(s, 1))
|
||||
return FALSE;
|
||||
|
||||
if (fast_glyph->cbData > 1)
|
||||
@ -1789,7 +1789,7 @@ BOOL update_read_cache_glyph_order(wStream* s, CACHE_GLYPH_ORDER* cache_glyph_or
|
||||
|
||||
if (flags & CG_GLYPH_UNICODE_PRESENT)
|
||||
{
|
||||
return stream_skip(s, cache_glyph_order->cGlyphs * 2);
|
||||
return Stream_SafeSeek(s, cache_glyph_order->cGlyphs * 2);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -1871,7 +1871,7 @@ BOOL update_read_cache_glyph_v2_order(wStream* s, CACHE_GLYPH_V2_ORDER* cache_gl
|
||||
|
||||
if (flags & CG_GLYPH_UNICODE_PRESENT)
|
||||
{
|
||||
return stream_skip(s, cache_glyph_v2->cGlyphs * 2);
|
||||
return Stream_SafeSeek(s, cache_glyph_v2->cGlyphs * 2);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -2144,7 +2144,7 @@ BOOL update_read_draw_gdiplus_first_order(wStream* s, DRAW_GDIPLUS_FIRST_ORDER*
|
||||
Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalSize); /* cbTotalSize (4 bytes) */
|
||||
Stream_Read_UINT32(s, draw_gdiplus_first->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */
|
||||
|
||||
return stream_skip(s, draw_gdiplus_first->cbSize); /* emfRecords */
|
||||
return Stream_SafeSeek(s, draw_gdiplus_first->cbSize); /* emfRecords */
|
||||
}
|
||||
|
||||
BOOL update_read_draw_gdiplus_next_order(wStream* s, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next)
|
||||
@ -2165,7 +2165,7 @@ BOOL update_read_draw_gdiplus_end_order(wStream* s, DRAW_GDIPLUS_END_ORDER* draw
|
||||
Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalSize); /* cbTotalSize (4 bytes) */
|
||||
Stream_Read_UINT32(s, draw_gdiplus_end->cbTotalEmfSize); /* cbTotalEmfSize (4 bytes) */
|
||||
|
||||
return stream_skip(s, draw_gdiplus_end->cbSize); /* emfRecords */
|
||||
return Stream_SafeSeek(s, draw_gdiplus_end->cbSize); /* emfRecords */
|
||||
}
|
||||
|
||||
BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_FIRST_ORDER* draw_gdiplus_cache_first)
|
||||
@ -2178,7 +2178,7 @@ BOOL update_read_draw_gdiplus_cache_first_order(wStream* s, DRAW_GDIPLUS_CACHE_F
|
||||
Stream_Read_UINT16(s, draw_gdiplus_cache_first->cbSize); /* cbSize (2 bytes) */
|
||||
Stream_Read_UINT32(s, draw_gdiplus_cache_first->cbTotalSize); /* cbTotalSize (4 bytes) */
|
||||
|
||||
return stream_skip(s, draw_gdiplus_cache_first->cbSize); /* emfRecords */
|
||||
return Stream_SafeSeek(s, draw_gdiplus_cache_first->cbSize); /* emfRecords */
|
||||
}
|
||||
|
||||
BOOL update_read_draw_gdiplus_cache_next_order(wStream* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next)
|
||||
@ -2203,7 +2203,7 @@ BOOL update_read_draw_gdiplus_cache_end_order(wStream* s, DRAW_GDIPLUS_CACHE_END
|
||||
Stream_Read_UINT16(s, draw_gdiplus_cache_end->cbSize); /* cbSize (2 bytes) */
|
||||
Stream_Read_UINT32(s, draw_gdiplus_cache_end->cbTotalSize); /* cbTotalSize (4 bytes) */
|
||||
|
||||
return stream_skip(s, draw_gdiplus_cache_end->cbSize); /* emfRecords */
|
||||
return Stream_SafeSeek(s, draw_gdiplus_cache_end->cbSize); /* emfRecords */
|
||||
}
|
||||
|
||||
BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes)
|
||||
|
@ -204,7 +204,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
|
||||
}
|
||||
}
|
||||
|
||||
if (!stream_skip(s, 8)) /* pad (8 bytes) */
|
||||
if (!Stream_SafeSeek(s, 8)) /* pad (8 bytes) */
|
||||
return FALSE;
|
||||
|
||||
if (redirection->flags & LB_NOREDIRECT)
|
||||
@ -220,9 +220,9 @@ BOOL rdp_recv_redirection_packet(rdpRdp* rdp, wStream* s)
|
||||
|
||||
BOOL rdp_recv_enhanced_security_redirection_packet(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
return stream_skip(s, 2) && /* pad2Octets (2 bytes) */
|
||||
return Stream_SafeSeek(s, 2) && /* pad2Octets (2 bytes) */
|
||||
rdp_recv_server_redirection_pdu(rdp, s) &&
|
||||
stream_skip(s, 1); /* pad2Octets (1 byte) */
|
||||
Stream_SafeSeek(s, 1); /* pad2Octets (1 byte) */
|
||||
}
|
||||
|
||||
rdpRedirection* redirection_new()
|
||||
|
@ -84,7 +84,7 @@ BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li)
|
||||
/* DST-REF (2 bytes) */
|
||||
/* SRC-REF (2 bytes) */
|
||||
/* Class 0 (1 byte) */
|
||||
return stream_skip(s, 5);
|
||||
return Stream_SafeSeek(s, 5);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -852,7 +852,7 @@ rdpTransport* transport_new(rdpSettings* settings)
|
||||
|
||||
/* buffers for blocking read/write */
|
||||
transport->ReceiveStream = StreamPool_Take(transport->ReceivePool, 0);
|
||||
transport->SendStream = stream_new(BUFFER_SIZE);
|
||||
transport->SendStream = Stream_New(NULL, BUFFER_SIZE);
|
||||
|
||||
transport->blocking = TRUE;
|
||||
|
||||
@ -874,7 +874,7 @@ void transport_free(rdpTransport* transport)
|
||||
|
||||
StreamPool_Free(transport->ReceivePool);
|
||||
|
||||
stream_free(transport->SendStream);
|
||||
Stream_Free(transport->SendStream, TRUE);
|
||||
CloseHandle(transport->ReceiveEvent);
|
||||
|
||||
CloseHandle(transport->connectedEvent);
|
||||
|
@ -375,7 +375,7 @@ BOOL ber_read_integer(wStream* s, UINT32* value)
|
||||
if (value == NULL)
|
||||
{
|
||||
// even if we don't care the integer value, check the announced size
|
||||
return stream_skip(s, length);
|
||||
return Stream_SafeSeek(s, length);
|
||||
}
|
||||
|
||||
if (length == 1)
|
||||
|
@ -116,9 +116,9 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT3
|
||||
if (dataFlags & CHANNEL_FLAG_FIRST)
|
||||
{
|
||||
if (plugin->data_in != NULL)
|
||||
stream_free(plugin->data_in);
|
||||
Stream_Free(plugin->data_in, TRUE);
|
||||
|
||||
plugin->data_in = stream_new(totalLength);
|
||||
plugin->data_in = Stream_New(NULL, totalLength);
|
||||
}
|
||||
|
||||
data_in = plugin->data_in;
|
||||
@ -167,7 +167,7 @@ static void svc_plugin_open_event(UINT32 openHandle, UINT32 event, void* pData,
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
stream_free((wStream*) pData);
|
||||
Stream_Free((wStream*) pData, TRUE);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_USER:
|
||||
@ -247,7 +247,7 @@ static void svc_plugin_process_terminated(rdpSvcPlugin* plugin)
|
||||
|
||||
if (plugin->data_in)
|
||||
{
|
||||
stream_free(plugin->data_in);
|
||||
Stream_Free(plugin->data_in, TRUE);
|
||||
plugin->data_in = NULL;
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ int svc_plugin_send(rdpSvcPlugin* plugin, wStream* data_out)
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
stream_free(data_out);
|
||||
Stream_Free(data_out, TRUE);
|
||||
fprintf(stderr, "svc_plugin_send: VirtualChannelWrite failed %d\n", status);
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ void mf_peer_context_new(freerdp_peer* client, mfPeerContext* context)
|
||||
//context->nsc_context = nsc_context_new();
|
||||
//nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_B8G8R8A8);
|
||||
|
||||
context->s = stream_new(0xFFFF);
|
||||
context->s = Stream_New(NULL, 0xFFFF);
|
||||
|
||||
//#ifdef WITH_SERVER_CHANNELS
|
||||
context->vcm = WTSCreateVirtualChannelManager(client);
|
||||
@ -203,7 +203,7 @@ void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context)
|
||||
|
||||
dispatch_suspend(info_timer);
|
||||
|
||||
stream_free(context->s);
|
||||
Stream_Free(context->s, TRUE);
|
||||
|
||||
rfx_context_free(context->rfx_context);
|
||||
//nsc_context_free(context->nsc_context);
|
||||
|
@ -55,7 +55,7 @@ void test_peer_context_new(freerdp_peer* client, testPeerContext* context)
|
||||
context->nsc_context = nsc_context_new();
|
||||
nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_R8G8B8);
|
||||
|
||||
context->s = stream_new(65536);
|
||||
context->s = Stream_New(NULL, 65536);
|
||||
|
||||
context->icon_x = -1;
|
||||
context->icon_y = -1;
|
||||
@ -74,7 +74,7 @@ void test_peer_context_free(freerdp_peer* client, testPeerContext* context)
|
||||
CloseHandle(context->debug_channel_thread);
|
||||
}
|
||||
|
||||
stream_free(context->s);
|
||||
Stream_Free(context->s, TRUE);
|
||||
free(context->icon_data);
|
||||
free(context->bg_data);
|
||||
|
||||
@ -362,7 +362,7 @@ void tf_peer_dump_rfx(freerdp_peer* client)
|
||||
rdpPcap* pcap_rfx;
|
||||
pcap_record record;
|
||||
|
||||
s = stream_new(512);
|
||||
s = Stream_New(NULL, 512);
|
||||
update = client->update;
|
||||
client->update->pcap_rfx = pcap_open(test_pcap_file, FALSE);
|
||||
pcap_rfx = client->update->pcap_rfx;
|
||||
@ -406,7 +406,7 @@ static void* tf_debug_channel_thread_func(void* arg)
|
||||
context->event = CreateWaitObjectEvent(NULL, TRUE, FALSE, fd);
|
||||
}
|
||||
|
||||
s = stream_new(4096);
|
||||
s = Stream_New(NULL, 4096);
|
||||
|
||||
WTSVirtualChannelWrite(context->debug_channel, (BYTE*) "test1", 5, NULL);
|
||||
|
||||
@ -440,7 +440,7 @@ static void* tf_debug_channel_thread_func(void* arg)
|
||||
printf("got %d bytes\n", bytes_returned);
|
||||
}
|
||||
|
||||
stream_free(s);
|
||||
Stream_Free(s, TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ void wf_update_encoder_reset(wfInfo* wfi)
|
||||
wfi->rfx_context->width = wfi->servscreen_width;
|
||||
wfi->rfx_context->height = wfi->servscreen_height;
|
||||
rfx_context_set_pixel_format(wfi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
|
||||
wfi->s = stream_new(0xFFFF);
|
||||
wfi->s = Stream_New(NULL, 0xFFFF);
|
||||
}
|
||||
|
||||
wf_info_invalidate_full_screen(wfi);
|
||||
|
@ -187,40 +187,34 @@ WINPR_API void Stream_Free(wStream* s, BOOL bFreeBuffer);
|
||||
_src->pointer += _n; \
|
||||
} while (0)
|
||||
|
||||
#define Stream_Pointer(_s) _s->pointer
|
||||
#define Stream_Buffer(_s) _s->buffer
|
||||
#define Stream_Length(_s) _s->length
|
||||
#define Stream_Capacity(_s) _s->capacity
|
||||
#define Stream_Buffer(_s) _s->buffer
|
||||
#define Stream_GetBuffer(_s, _b) _b = _s->buffer
|
||||
#define Stream_SetBuffer(_s, _b) _s->buffer = _b
|
||||
|
||||
#define Stream_Pointer(_s) _s->pointer
|
||||
#define Stream_GetPointer(_s, _p) _p = _s->pointer
|
||||
#define Stream_SetPointer(_s, _p) _s->pointer = _p
|
||||
|
||||
#define Stream_Length(_s) _s->length
|
||||
#define Stream_GetLength(_s, _l) _l = _s->length
|
||||
#define Stream_SetLength(_s, _l) _s->length = _l
|
||||
|
||||
#define Stream_Capacity(_s) _s->capacity
|
||||
#define Stream_GetCapacity(_s, _c) _c = _s->capacity
|
||||
#define Stream_SetCapacity(_s, _c) _s->capacity = _c
|
||||
|
||||
#define Stream_GetPosition(_s) (_s->pointer - _s->buffer)
|
||||
#define Stream_SetPosition(_s, _p) _s->pointer = _s->buffer + (_p)
|
||||
|
||||
#define Stream_GetPointer(_s, _p) _p = _s->pointer
|
||||
#define Stream_SetPointer(_s, _p) _s->pointer = _p
|
||||
|
||||
#define Stream_SealLength(_s) _s->length = (_s->pointer - _s->buffer)
|
||||
#define Stream_GetRemainingLength(_s) (_s->length - (_s->pointer - _s->buffer))
|
||||
|
||||
#define Stream_Clear(_s) memset(_s->buffer, 0, _s->capacity)
|
||||
|
||||
/* Deprecated STREAM API */
|
||||
|
||||
WINPR_API wStream* stream_new(int size);
|
||||
WINPR_API void stream_free(wStream* stream);
|
||||
|
||||
#define stream_attach(_s, _buf, _size) do { \
|
||||
_s->capacity = _size; \
|
||||
_s->length = _size; \
|
||||
_s->buffer = _buf; \
|
||||
_s->pointer = _buf; } while (0)
|
||||
#define stream_detach(_s) memset(_s, 0, sizeof(wStream))
|
||||
|
||||
WINPR_API void stream_extend(wStream* stream, int request_size);
|
||||
|
||||
static INLINE BOOL stream_skip(wStream* s, size_t sz) {
|
||||
if (Stream_GetRemainingLength(s) < sz)
|
||||
static INLINE BOOL Stream_SafeSeek(wStream* s, size_t size) {
|
||||
if (Stream_GetRemainingLength(s) < size)
|
||||
return FALSE;
|
||||
Stream_Seek(s, sz);
|
||||
Stream_Seek(s, size);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -86,65 +86,3 @@ void Stream_Free(wStream* s, BOOL bFreeBuffer)
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
|
||||
/* Deprecated STREAM API */
|
||||
|
||||
/**
|
||||
* Allocates and initializes a STREAM structure.
|
||||
* STREAM are used to ease data access in read and write operations.
|
||||
* They consist of a buffer containing the data we want to access, and an offset associated to it, and keeping
|
||||
* track of the 'current' position in the stream. A list of functions can then be used to read/write different
|
||||
* type of data to/from it.
|
||||
* @see stream.h for the list of data access functions.
|
||||
*
|
||||
* @param size [in] - size of the buffer that will ba allocated to the stream.
|
||||
* If 0, there will be no buffer attached to the stream. The caller
|
||||
* then needs to call stream_attach() to link an existing buffer to this stream.
|
||||
* Caution: calling stream_attach() on a stream with an existing buffer will result
|
||||
* in this buffer being lost, and possible memory leak.
|
||||
*
|
||||
* @return A pointer to an allocated and initialized STREAM structure.
|
||||
* This pointer need to be deallocated using the stream_free() function.
|
||||
*/
|
||||
wStream* stream_new(int size)
|
||||
{
|
||||
wStream* stream;
|
||||
|
||||
stream = malloc(sizeof(wStream));
|
||||
ZeroMemory(stream, sizeof(wStream));
|
||||
|
||||
if (stream != NULL)
|
||||
{
|
||||
if (size != 0)
|
||||
{
|
||||
size = size > 0 ? size : 0x400;
|
||||
stream->buffer = (BYTE*) malloc(size);
|
||||
ZeroMemory(stream->buffer, size);
|
||||
stream->pointer = stream->buffer;
|
||||
stream->capacity = size;
|
||||
stream->length = size;
|
||||
}
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to deallocate a stream that was allocated using stream_new().
|
||||
* Caution: the buffer linked to the stream will be deallocated in the process. If this buffer was attached
|
||||
* using the stream_attach() function, the stream_detach() function needs to be called before calling stream_free()
|
||||
* otherwise it will be freed in the process.
|
||||
*
|
||||
* @param stream [in] - Pointer to the STREAM structure that needs to be deallocated.
|
||||
* This pointer is invalid on return.
|
||||
*/
|
||||
void stream_free(wStream* stream)
|
||||
{
|
||||
if (stream != NULL)
|
||||
{
|
||||
if (stream->buffer != NULL)
|
||||
free(stream->buffer);
|
||||
|
||||
free(stream);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user