mirror of https://github.com/FreeRDP/FreeRDP
libfreerdp-core: modify server-side confirm active pdu receiving logic
This commit is contained in:
parent
6cde25937d
commit
91103b76b3
|
@ -250,6 +250,7 @@ BOOL rdp_recv_server_font_map_pdu(rdpRdp* rdp, wStream* s)
|
|||
BOOL rdp_recv_client_font_map_pdu(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
rdp->finalize_sc_pdus |= FINALIZE_SC_FONT_MAP_PDU;
|
||||
|
||||
if(Stream_GetRemainingLength(s) >= 8)
|
||||
{
|
||||
Stream_Seek_UINT16(s); /* numberEntries (2 bytes) */
|
||||
|
|
|
@ -3155,8 +3155,6 @@ BOOL rdp_read_capability_sets(wStream* s, rdpSettings* settings, UINT16 numberCa
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
printf("Caps %d of %d\n", count - numberCapabilities + 1, count);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CAPSET_TYPE_GENERAL:
|
||||
|
@ -3504,25 +3502,10 @@ BOOL rdp_send_demand_active(rdpRdp* rdp)
|
|||
BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
BOOL status;
|
||||
UINT16 channelId;
|
||||
UINT16 pduType;
|
||||
UINT16 pduLength;
|
||||
UINT16 pduSource;
|
||||
UINT16 lengthSourceDescriptor;
|
||||
UINT16 lengthCombinedCapabilities;
|
||||
UINT16 numberCapabilities;
|
||||
|
||||
if (!rdp_recv_get_active_header(rdp, s, &channelId))
|
||||
return FALSE;
|
||||
|
||||
if (!rdp_read_share_control_header(s, &pduLength, &pduType, &pduSource))
|
||||
return FALSE;
|
||||
|
||||
rdp->settings->PduSource = pduSource;
|
||||
|
||||
if (pduType != PDU_TYPE_CONFIRM_ACTIVE)
|
||||
return FALSE;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 10)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -933,9 +933,14 @@ BOOL rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, wStream* s)
|
|||
|
||||
BOOL rdp_server_accept_confirm_active(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
if (rdp->state != CONNECTION_STATE_CAPABILITIES_EXCHANGE)
|
||||
return FALSE;
|
||||
|
||||
if (!rdp_recv_confirm_active(rdp, s))
|
||||
return FALSE;
|
||||
|
||||
rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION);
|
||||
|
||||
if (!rdp_send_server_synchronize_pdu(rdp))
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -356,15 +356,15 @@ BOOL mcs_recv_connect_initial(rdpMcs* mcs, wStream* s)
|
|||
return FALSE;
|
||||
|
||||
/* targetParameters (DomainParameters) */
|
||||
if(!mcs_read_domain_parameters(s, &mcs->targetParameters))
|
||||
if (!mcs_read_domain_parameters(s, &mcs->targetParameters))
|
||||
return FALSE;
|
||||
|
||||
/* minimumParameters (DomainParameters) */
|
||||
if(!mcs_read_domain_parameters(s, &mcs->minimumParameters))
|
||||
if (!mcs_read_domain_parameters(s, &mcs->minimumParameters))
|
||||
return FALSE;
|
||||
|
||||
/* maximumParameters (DomainParameters) */
|
||||
if(!mcs_read_domain_parameters(s, &mcs->maximumParameters))
|
||||
if (!mcs_read_domain_parameters(s, &mcs->maximumParameters))
|
||||
return FALSE;
|
||||
|
||||
if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length)
|
||||
|
@ -510,7 +510,7 @@ BOOL mcs_recv_connect_response(rdpMcs* mcs, wStream* s)
|
|||
if (!tpdu_read_data(s, &li))
|
||||
return FALSE;
|
||||
|
||||
if(!ber_read_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, &length) ||
|
||||
if (!ber_read_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, &length) ||
|
||||
!ber_read_enumerated(s, &result, MCS_Result_enum_length) ||
|
||||
!ber_read_integer(s, &calledConnectId) ||
|
||||
!mcs_read_domain_parameters(s, &(mcs->domainParameters)) ||
|
||||
|
|
|
@ -136,7 +136,7 @@ static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s)
|
|||
return FALSE;
|
||||
|
||||
case DATA_PDU_TYPE_FRAME_ACKNOWLEDGE:
|
||||
if(Stream_GetRemainingLength(s) < 4)
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
return FALSE;
|
||||
Stream_Read_UINT32(s, client->ack_frame_id);
|
||||
IFCALL(client->update->SurfaceFrameAcknowledge, client->update->context, client->ack_frame_id);
|
||||
|
@ -195,7 +195,7 @@ static int peer_recv_tpkt_pdu(freerdp_peer* client, wStream* s)
|
|||
|
||||
if (channelId != MCS_GLOBAL_CHANNEL_ID)
|
||||
{
|
||||
if(!freerdp_channel_peer_process(client, s, channelId))
|
||||
if (!freerdp_channel_peer_process(client, s, channelId))
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
@ -265,8 +265,6 @@ static int peer_recv_callback(rdpTransport* transport, wStream* s, void* extra)
|
|||
freerdp_peer* client = (freerdp_peer*) extra;
|
||||
rdpRdp* rdp = client->context->rdp;
|
||||
|
||||
printf("rdp->state: %d\n", rdp->state);
|
||||
|
||||
switch (rdp->state)
|
||||
{
|
||||
case CONNECTION_STATE_INITIAL:
|
||||
|
@ -363,17 +361,8 @@ static int peer_recv_callback(rdpTransport* transport, wStream* s, void* extra)
|
|||
* before receiving the Deactivate All PDU. We need to process them as usual.
|
||||
*/
|
||||
|
||||
if (!rdp_server_accept_confirm_active(rdp, s))
|
||||
{
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
if (peer_recv_pdu(client, s) < 0)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION);
|
||||
}
|
||||
if (peer_recv_pdu(client, s) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -236,8 +236,9 @@ wStream* rdp_data_pdu_init(rdpRdp* rdp)
|
|||
* @param channel_id channel id
|
||||
*/
|
||||
|
||||
BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id)
|
||||
BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channelId)
|
||||
{
|
||||
BYTE byte;
|
||||
UINT16 initiator;
|
||||
enum DomainMCSPDU MCSPDU;
|
||||
|
||||
|
@ -274,8 +275,8 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id
|
|||
return FALSE;
|
||||
|
||||
per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
|
||||
per_read_integer16(s, channel_id, 0); /* channelId */
|
||||
Stream_Seek(s, 1); /* dataPriority + Segmentation (0x70) */
|
||||
per_read_integer16(s, channelId, 0); /* channelId */
|
||||
Stream_Read_UINT8(s, byte); /* dataPriority + Segmentation (0x70) */
|
||||
|
||||
if (!per_read_length(s, length)) /* userData (OCTET_STRING) */
|
||||
return FALSE;
|
||||
|
@ -294,7 +295,7 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channel_id
|
|||
* @param channel_id channel id
|
||||
*/
|
||||
|
||||
void rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channel_id)
|
||||
void rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channelId)
|
||||
{
|
||||
int body_length;
|
||||
enum DomainMCSPDU MCSPDU;
|
||||
|
@ -314,10 +315,10 @@ void rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channel_id)
|
|||
|
||||
mcs_write_domain_mcspdu_header(s, MCSPDU, length, 0);
|
||||
per_write_integer16(s, rdp->mcs->user_id, MCS_BASE_CHANNEL_ID); /* initiator */
|
||||
per_write_integer16(s, channel_id, 0); /* channelId */
|
||||
per_write_integer16(s, channelId, 0); /* channelId */
|
||||
Stream_Write_UINT8(s, 0x70); /* dataPriority + segmentation */
|
||||
/*
|
||||
* We always encode length in two bytes, eventhough we could use
|
||||
* We always encode length in two bytes, even though we could use
|
||||
* only one byte if length <= 0x7F. It is just easier that way,
|
||||
* because we can leave room for fixed-length header, store all
|
||||
* the data first and then store the header.
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <winpr/print.h>
|
||||
|
||||
#include "tpdu.h"
|
||||
|
||||
|
@ -66,9 +67,9 @@
|
|||
* @return TPDU length indicator (LI)
|
||||
*/
|
||||
|
||||
BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li)
|
||||
BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE* li)
|
||||
{
|
||||
if(Stream_GetRemainingLength(s) < 3)
|
||||
if (Stream_GetRemainingLength(s) < 3)
|
||||
return FALSE;
|
||||
|
||||
Stream_Read_UINT8(s, *li); /* LI */
|
||||
|
@ -86,6 +87,7 @@ BOOL tpdu_read_header(wStream* s, BYTE* code, BYTE *li)
|
|||
/* Class 0 (1 byte) */
|
||||
return Stream_SafeSeek(s, 5);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -205,16 +207,18 @@ void tpdu_write_data(wStream* s)
|
|||
* @param s stream
|
||||
*/
|
||||
|
||||
BOOL tpdu_read_data(wStream* s, UINT16 *LI)
|
||||
BOOL tpdu_read_data(wStream* s, UINT16* LI)
|
||||
{
|
||||
BYTE code;
|
||||
BYTE li;
|
||||
|
||||
if(!tpdu_read_header(s, &code, &li))
|
||||
if (!tpdu_read_header(s, &code, &li))
|
||||
return FALSE;
|
||||
|
||||
if (code != X224_TPDU_DATA)
|
||||
return FALSE;
|
||||
|
||||
*LI = li;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue