Fixed missing check for fastpath input messages

Input events are only allowed after a connection was established
(connection state is active)
This check aborts input sending when done before that.
This commit is contained in:
akallabeth 2021-01-22 08:24:16 +01:00
parent 53a2563711
commit 102869f6a8
4 changed files with 21 additions and 4 deletions

View File

@ -1589,3 +1589,10 @@ const char* rdp_server_connection_state_string(int state)
return "UNKNOWN";
}
}
int rdp_client_get_state(rdpRdp* rdp)
{
if (!rdp)
return -1;
return rdp->state;
}

View File

@ -67,6 +67,7 @@ FREERDP_LOCAL int rdp_client_connect_license(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_transition_to_state(rdpRdp* rdp, int state);
FREERDP_LOCAL const char* rdp_client_connection_state_string(int state);
FREERDP_LOCAL int rdp_client_get_state(rdpRdp* rdp);
FREERDP_LOCAL BOOL rdp_server_accept_nego(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL BOOL rdp_server_accept_mcs_connect_initial(rdpRdp* rdp, wStream* s);

View File

@ -934,8 +934,9 @@ wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags, BYTE ev
return s;
}
BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNumEvents)
BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, size_t iNumEvents)
{
int state;
BOOL rc = FALSE;
rdpRdp* rdp;
UINT16 length;
@ -944,9 +945,18 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNu
if (!s)
return FALSE;
if (!fastpath || !fastpath->rdp)
if (!fastpath)
goto fail;
rdp = fastpath->rdp;
state = rdp_client_get_state(rdp);
if (state != CONNECTION_STATE_ACTIVE)
{
WLog_WARN(TAG, "[%s] called before activation [%s]", __FUNCTION__,
rdp_client_connection_state_string(state));
goto fail;
}
/*
* A maximum of 15 events are allowed per request
* if the optional numEvents field isn't used
@ -955,7 +965,6 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, int iNu
if (iNumEvents > 15)
goto fail;
rdp = fastpath->rdp;
length = Stream_GetPosition(s);
if (length >= (2 << 14))

View File

@ -160,7 +160,7 @@ FREERDP_LOCAL wStream* fastpath_input_pdu_init_header(rdpFastPath* fastpath);
FREERDP_LOCAL wStream* fastpath_input_pdu_init(rdpFastPath* fastpath, BYTE eventFlags,
BYTE eventCode);
FREERDP_LOCAL BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s,
int iEventCount);
size_t iEventCount);
FREERDP_LOCAL BOOL fastpath_send_input_pdu(rdpFastPath* fastpath, wStream* s);
FREERDP_LOCAL wStream* fastpath_update_pdu_init(rdpFastPath* fastpath);