[core] Check return value of *_transition_to_state

The state transition might not be allowed, so abort if that fails.
This commit is contained in:
akallabeth 2022-11-15 14:19:54 +01:00 committed by akallabeth
parent 7bbb8706ee
commit 4ccb38aa13
5 changed files with 187 additions and 115 deletions

View File

@ -260,7 +260,7 @@ static BOOL rdp_write_client_persistent_key_list_pdu(wStream* s, RDP_BITMAP_PERS
Stream_Write_UINT16(s, 0); /* pad3 (2 bytes) */
/* entries */
if (!Stream_EnsureRemainingCapacity(s, info->keyCount * 8))
if (!Stream_EnsureRemainingCapacity(s, info->keyCount * 8ull))
return FALSE;
for (index = 0; index < info->keyCount; index++)
@ -312,7 +312,7 @@ static UINT32 rdp_load_persistent_key_list(rdpRdp* rdp, UINT64** pKeyList)
for (index = 0; index < count; index++)
{
PERSISTENT_CACHE_ENTRY cacheEntry;
PERSISTENT_CACHE_ENTRY cacheEntry = { 0 };
if (persistent_cache_read_entry(persistent, &cacheEntry) < 1)
continue;
@ -753,19 +753,27 @@ BOOL rdp_server_accept_client_font_list_pdu(rdpRdp* rdp, wStream* s)
return FALSE;
rdp_finalize_set_flag(rdp, FINALIZE_CS_FONT_LIST_PDU);
rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_SYNC);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_SYNC))
return FALSE;
if (!rdp_send_server_synchronize_pdu(rdp))
return FALSE;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_COOPERATE);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_COOPERATE))
return FALSE;
if (!rdp_send_server_control_cooperate_pdu(rdp))
return FALSE;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_GRANTED_CONTROL);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_GRANTED_CONTROL))
return FALSE;
if (!rdp_send_server_control_granted_pdu(rdp))
return FALSE;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_FONT_MAP);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_FONT_MAP))
return FALSE;
if (!rdp_send_server_font_map_pdu(rdp))
return FALSE;

View File

@ -345,7 +345,8 @@ BOOL rdp_client_connect(rdpRdp* rdp)
if (!freerdp_settings_get_bool(settings, FreeRDP_TransportDumpReplay))
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_NEGO);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_NEGO))
return FALSE;
if (!nego_connect(rdp->nego))
{
@ -379,7 +380,8 @@ BOOL rdp_client_connect(rdpRdp* rdp)
}
else
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_REQUEST);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_REQUEST))
return FALSE;
}
/* everything beyond this point is event-driven and non blocking */
@ -451,7 +453,8 @@ BOOL rdp_client_disconnect(rdpRdp* rdp)
if (!rdp_reset(rdp))
return FALSE;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_INITIAL);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_INITIAL))
return FALSE;
if (freerdp_channels_disconnect(context->channels, context->instance) != CHANNEL_RC_OK)
return FALSE;
@ -703,7 +706,8 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp)
return TRUE;
}
rdp_client_transition_to_state(rdp, CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT))
return FALSE;
/* encrypt client random */
free(settings->ClientRandom);
@ -960,10 +964,12 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s)
mcs->userChannelJoined = TRUE;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST))
return FALSE;
if (!mcs_send_channel_join_request(mcs, MCS_GLOBAL_CHANNEL_ID))
return FALSE;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE))
return FALSE;
}
else if (!mcs->globalChannelJoined)
{
@ -974,10 +980,12 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s)
if (mcs->messageChannelId != 0)
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST))
return FALSE;
if (!mcs_send_channel_join_request(mcs, mcs->messageChannelId))
return FALSE;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE))
return FALSE;
allJoined = FALSE;
}
@ -986,10 +994,13 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s)
if (mcs->channelCount > 0)
{
const rdpMcsChannel* cur = &mcs->channels[0];
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST))
return FALSE;
if (!mcs_send_channel_join_request(mcs, cur->ChannelId))
return FALSE;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE);
if (!rdp_client_transition_to_state(rdp,
CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE))
return FALSE;
allJoined = FALSE;
}
@ -1005,10 +1016,12 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s)
if (mcs->channelCount > 0)
{
const rdpMcsChannel* cur = &mcs->channels[0];
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST))
return FALSE;
if (!mcs_send_channel_join_request(mcs, cur->ChannelId))
return FALSE;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE))
return FALSE;
allJoined = FALSE;
}
@ -1031,10 +1044,12 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s)
if (i + 1 < mcs->channelCount)
{
const rdpMcsChannel* cur = &mcs->channels[i + 1];
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST))
return FALSE;
if (!mcs_send_channel_join_request(mcs, cur->ChannelId))
return FALSE;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE))
return FALSE;
allJoined = FALSE;
}
@ -1045,11 +1060,12 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s)
if (!rdp_client_establish_keys(rdp))
return FALSE;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE))
return FALSE;
if (!rdp_send_client_info(rdp))
return FALSE;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT_REQUEST);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT_REQUEST))
return FALSE;
}
return TRUE;
@ -1134,13 +1150,15 @@ state_run_t rdp_client_connect_license(rdpRdp* rdp, wStream* s)
case LICENSE_STATE_COMPLETED:
if (rdp->settings->MultitransportFlags)
{
rdp_client_transition_to_state(
rdp, CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING_REQUEST);
if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING_REQUEST))
return STATE_RUN_FAILED;
}
else
{
rdp_client_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE);
if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE))
return STATE_RUN_FAILED;
}
return STATE_RUN_SUCCESS;
default:
@ -1190,15 +1208,19 @@ state_run_t rdp_client_connect_finalize(rdpRdp* rdp)
* server-to- client PDUs; they may be sent as a single batch, provided that sequencing is
* maintained.
*/
rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_SYNC);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_SYNC))
return STATE_RUN_FAILED;
if (!rdp_send_client_synchronize_pdu(rdp))
return STATE_RUN_FAILED;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_COOPERATE);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_COOPERATE))
return STATE_RUN_FAILED;
if (!rdp_send_client_control_pdu(rdp, CTRLACTION_COOPERATE))
return STATE_RUN_FAILED;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_REQUEST_CONTROL);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_REQUEST_CONTROL))
return STATE_RUN_FAILED;
if (!rdp_send_client_control_pdu(rdp, CTRLACTION_REQUEST_CONTROL))
return STATE_RUN_FAILED;
@ -1212,16 +1234,19 @@ state_run_t rdp_client_connect_finalize(rdpRdp* rdp)
if (!rdp_finalize_is_flag_set(rdp, FINALIZE_DEACTIVATE_REACTIVATE) &&
rdp->settings->BitmapCachePersistEnabled)
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_PERSISTENT_KEY_LIST);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_PERSISTENT_KEY_LIST))
return STATE_RUN_FAILED;
if (!rdp_send_client_persistent_key_list_pdu(rdp))
return STATE_RUN_FAILED;
}
rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_FONT_LIST);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_FONT_LIST))
return STATE_RUN_FAILED;
if (!rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST | FONTLIST_LAST))
return STATE_RUN_FAILED;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_SYNC);
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_CLIENT_SYNC))
return STATE_RUN_FAILED;
return STATE_RUN_SUCCESS;
}
@ -1417,10 +1442,12 @@ BOOL rdp_server_accept_mcs_connect_initial(rdpRdp* rdp, wStream* s)
}
}
rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_RESPONSE);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_RESPONSE))
return FALSE;
if (!mcs_send_connect_response(mcs))
return FALSE;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_ERECT_DOMAIN);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_ERECT_DOMAIN))
return FALSE;
return TRUE;
}
@ -1434,22 +1461,24 @@ BOOL rdp_server_accept_mcs_erect_domain_request(rdpRdp* rdp, wStream* s)
if (!mcs_recv_erect_domain_request(rdp->mcs, s))
return FALSE;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER);
return TRUE;
return rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER);
}
BOOL rdp_server_accept_mcs_attach_user_request(rdpRdp* rdp, wStream* s)
{
rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER))
return FALSE;
if (!mcs_recv_attach_user_request(rdp->mcs, s))
return FALSE;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER_CONFIRM);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER_CONFIRM))
return FALSE;
if (!mcs_send_attach_user_confirm(rdp->mcs))
return FALSE;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST);
return TRUE;
return rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST);
}
BOOL rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, wStream* s)
@ -1470,7 +1499,9 @@ BOOL rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, wStream* s)
if (!mcs_recv_channel_join_request(mcs, rdp->context->settings, s, &channelId))
return FALSE;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE))
return FALSE;
if (!mcs_send_channel_join_confirm(mcs, channelId))
return FALSE;
@ -1491,13 +1522,14 @@ BOOL rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, wStream* s)
allJoined = FALSE;
}
CONNECTION_STATE rc;
if ((mcs->userChannelJoined) && (mcs->globalChannelJoined) &&
(mcs->messageChannelId == 0 || mcs->messageChannelJoined) && allJoined)
rdp_server_transition_to_state(rdp, CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT);
rc = CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT;
else
rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST);
rc = CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST;
return TRUE;
return rdp_server_transition_to_state(rdp, rc);
}
BOOL rdp_server_accept_confirm_active(rdpRdp* rdp, wStream* s, UINT16 pduLength)
@ -1533,9 +1565,7 @@ BOOL rdp_server_accept_confirm_active(rdpRdp* rdp, wStream* s, UINT16 pduLength)
if (rdp->settings->SaltedChecksum)
rdp->do_secure_checksum = TRUE;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_SYNC);
return TRUE;
return rdp_server_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION_SYNC);
}
BOOL rdp_server_reactivate(rdpRdp* rdp)

View File

@ -243,7 +243,8 @@ static BOOL freerdp_peer_initialize(freerdp_peer* client)
settings->ServerMode = TRUE;
settings->FrameAcknowledge = 0;
settings->LocalConnection = client->local;
rdp_server_transition_to_state(rdp, CONNECTION_STATE_INITIAL);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_INITIAL))
return FALSE;
if (settings->PrivateKeyFile)
{
@ -544,8 +545,9 @@ static state_run_t peer_recv_handle_auto_detect(freerdp_peer* client, wStream* s
if (autodetect_send_connecttime_rtt_measure_request(rdp->autodetect,
RDP_TRANSPORT_TCP, 0x23))
ret = STATE_RUN_SUCCESS;
rdp_server_transition_to_state(rdp,
CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT_RESPONSE);
if (!rdp_server_transition_to_state(
rdp, CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT_RESPONSE))
return STATE_RUN_FAILED;
}
break;
case CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT_RESPONSE:
@ -556,11 +558,13 @@ static state_run_t peer_recv_handle_auto_detect(freerdp_peer* client, wStream* s
switch (autodetect_get_state(rdp->autodetect))
{
case AUTODETECT_STATE_COMPLETE:
rdp_server_transition_to_state(rdp, CONNECTION_STATE_LICENSING);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_LICENSING))
return STATE_RUN_FAILED;
ret = STATE_RUN_CONTINUE; /* Rerun in next state */
break;
case AUTODETECT_STATE_RESPONSE:
rdp_server_transition_to_state(rdp, CONNECTION_STATE_LICENSING);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_LICENSING))
return STATE_RUN_FAILED;
ret = STATE_RUN_CONTINUE; /* Rerun in next state */
break;
default:
@ -576,7 +580,8 @@ static state_run_t peer_recv_handle_auto_detect(freerdp_peer* client, wStream* s
}
else
{
rdp_server_transition_to_state(rdp, CONNECTION_STATE_LICENSING);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_LICENSING))
return STATE_RUN_FAILED;
ret = STATE_RUN_CONTINUE; /* Rerun in next state */
}
@ -720,7 +725,9 @@ state_run_t rdp_peer_handle_state_demand_active(freerdp_peer* client)
}
else
{
rdp_server_transition_to_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT);
if (!rdp_server_transition_to_state(rdp,
CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT))
return STATE_RUN_FAILED;
ret = STATE_RUN_CONTINUE;
}
return ret;
@ -799,8 +806,8 @@ static state_run_t peer_recv_callback_internal(rdpTransport* transport, wStream*
switch (rdp_get_state(rdp))
{
case CONNECTION_STATE_INITIAL:
rdp_server_transition_to_state(rdp, CONNECTION_STATE_NEGO);
ret = STATE_RUN_CONTINUE;
if (rdp_server_transition_to_state(rdp, CONNECTION_STATE_NEGO))
ret = STATE_RUN_CONTINUE;
break;
case CONNECTION_STATE_NEGO:
@ -829,8 +836,8 @@ static state_run_t peer_recv_callback_internal(rdpTransport* transport, wStream*
IFCALLRET(client->Logon, client->authenticated, client, &client->identity,
FALSE);
}
rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_REQUEST);
ret = STATE_RUN_SUCCESS;
if (rdp_server_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_REQUEST))
ret = STATE_RUN_SUCCESS;
}
break;
@ -904,9 +911,9 @@ static state_run_t peer_recv_callback_internal(rdpTransport* transport, wStream*
}
if (state_run_success(ret))
{
rdp_server_transition_to_state(rdp, CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE);
if (Stream_GetRemainingLength(s) > 0)
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE))
ret = STATE_RUN_FAILED;
else if (Stream_GetRemainingLength(s) > 0)
ret = STATE_RUN_CONTINUE; /* Rerun function */
}
break;
@ -921,9 +928,9 @@ static state_run_t peer_recv_callback_internal(rdpTransport* transport, wStream*
}
else
{
rdp_server_transition_to_state(rdp,
CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT_REQUEST);
ret = STATE_RUN_CONTINUE;
if (rdp_server_transition_to_state(
rdp, CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT_REQUEST))
ret = STATE_RUN_CONTINUE;
}
break;
@ -935,16 +942,19 @@ static state_run_t peer_recv_callback_internal(rdpTransport* transport, wStream*
}
else
{
rdp_server_transition_to_state(rdp, CONNECTION_STATE_LICENSING);
ret = STATE_RUN_CONTINUE;
if (rdp_server_transition_to_state(rdp, CONNECTION_STATE_LICENSING))
ret = STATE_RUN_CONTINUE;
}
break;
case CONNECTION_STATE_LICENSING:
ret = peer_recv_handle_licensing(client, s);
if (ret == STATE_RUN_CONTINUE)
rdp_server_transition_to_state(
rdp, CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING_REQUEST);
{
if (!rdp_server_transition_to_state(
rdp, CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING_REQUEST))
ret = STATE_RUN_FAILED;
}
break;
case CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING_REQUEST:
@ -954,16 +964,16 @@ static state_run_t peer_recv_callback_internal(rdpTransport* transport, wStream*
ret = STATE_RUN_FAILED;
else
{
rdp_server_transition_to_state(
rdp, CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING_RESPONSE);
ret = STATE_RUN_CONTINUE;
if (rdp_server_transition_to_state(
rdp, CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING_RESPONSE))
ret = STATE_RUN_CONTINUE;
}
}
else
{
rdp_server_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE);
ret = STATE_RUN_CONTINUE; /* Rerun, initialize next state */
if (rdp_server_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE))
ret = STATE_RUN_CONTINUE; /* Rerun, initialize next state */
}
break;
case CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING_RESPONSE:
@ -1024,8 +1034,9 @@ static state_run_t peer_recv_callback_internal(rdpTransport* transport, wStream*
}
else
ret = STATE_RUN_SUCCESS;
rdp_server_transition_to_state(rdp,
CONNECTION_STATE_CAPABILITIES_EXCHANGE_CONFIRM_ACTIVE);
if (!rdp_server_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_CONFIRM_ACTIVE))
ret = STATE_RUN_FAILED;
break;
case CONNECTION_STATE_CAPABILITIES_EXCHANGE_CONFIRM_ACTIVE:

View File

@ -1632,8 +1632,10 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
switch (rdp_get_state(rdp))
{
case CONNECTION_STATE_NEGO:
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_REQUEST);
status = STATE_RUN_CONTINUE;
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_REQUEST))
status = STATE_RUN_FAILED;
else
status = STATE_RUN_CONTINUE;
break;
case CONNECTION_STATE_NLA:
if (nla_get_state(rdp->nla) < NLA_STATE_AUTH_INFO)
@ -1692,8 +1694,10 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
if (nla_get_state(rdp->nla) == NLA_STATE_FINAL)
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_REQUEST);
status = STATE_RUN_TRY_AGAIN;
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_REQUEST))
status = STATE_RUN_FAILED;
else
status = STATE_RUN_TRY_AGAIN;
}
}
break;
@ -1705,10 +1709,9 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
rdp_get_state_string(rdp));
status = STATE_RUN_FAILED;
}
else
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_RESPONSE);
}
else if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CREATE_RESPONSE))
status = STATE_RUN_FAILED;
break;
case CONNECTION_STATE_MCS_CREATE_RESPONSE:
@ -1719,23 +1722,25 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
}
else
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_ERECT_DOMAIN);
if (!mcs_send_erect_domain_request(rdp->mcs))
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_ERECT_DOMAIN))
status = STATE_RUN_FAILED;
else if (!mcs_send_erect_domain_request(rdp->mcs))
{
WLog_ERR(TAG, "mcs_send_erect_domain_request failure");
status = STATE_RUN_FAILED;
}
else
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER);
if (!mcs_send_attach_user_request(rdp->mcs))
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER))
status = STATE_RUN_FAILED;
else if (!mcs_send_attach_user_request(rdp->mcs))
{
WLog_ERR(TAG, "mcs_send_attach_user_request failure");
status = STATE_RUN_FAILED;
}
else
rdp_client_transition_to_state(rdp,
CONNECTION_STATE_MCS_ATTACH_USER_CONFIRM);
else if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_MCS_ATTACH_USER_CONFIRM))
status = STATE_RUN_FAILED;
}
}
break;
@ -1748,14 +1753,16 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
}
else
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST);
if (!mcs_send_channel_join_request(rdp->mcs, rdp->mcs->userId))
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_REQUEST))
status = STATE_RUN_FAILED;
else if (!mcs_send_channel_join_request(rdp->mcs, rdp->mcs->userId))
{
WLog_ERR(TAG, "mcs_send_channel_join_request failure");
status = STATE_RUN_FAILED;
}
else
rdp_client_transition_to_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE);
else if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN_RESPONSE))
status = STATE_RUN_FAILED;
}
break;
@ -1774,8 +1781,10 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
case CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT_REQUEST:
if (!rdp_client_connect_auto_detect(rdp, s))
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_LICENSING);
status = STATE_RUN_TRY_AGAIN;
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_LICENSING))
status = STATE_RUN_FAILED;
else
status = STATE_RUN_TRY_AGAIN;
}
break;
@ -1817,14 +1826,17 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
{
if (!rdp->settings->SupportMonitorLayoutPdu)
{
rdp_client_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_CONFIRM_ACTIVE);
status = STATE_RUN_TRY_AGAIN;
if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_CONFIRM_ACTIVE))
status = STATE_RUN_FAILED;
else
status = STATE_RUN_TRY_AGAIN;
}
else
{
rdp_client_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT);
if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT))
status = STATE_RUN_FAILED;
}
}
break;
@ -1834,8 +1846,9 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
if (state_run_success(status))
{
status = STATE_RUN_TRY_AGAIN;
rdp_client_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_CONFIRM_ACTIVE);
if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_CONFIRM_ACTIVE))
status = STATE_RUN_FAILED;
}
break;
@ -1851,8 +1864,11 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
{
const UINT32 uflags = rdp->finalize_sc_pdus & mask;
if (flags != uflags)
rdp_client_transition_to_state(rdp,
CONNECTION_STATE_FINALIZATION_CLIENT_COOPERATE);
{
if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_FINALIZATION_CLIENT_COOPERATE))
status = STATE_RUN_FAILED;
}
else
status = STATE_RUN_FAILED;
}
@ -1866,8 +1882,11 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
{
const UINT32 uflags = rdp->finalize_sc_pdus & mask;
if (flags != uflags)
rdp_client_transition_to_state(
rdp, CONNECTION_STATE_FINALIZATION_CLIENT_GRANTED_CONTROL);
{
if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_FINALIZATION_CLIENT_GRANTED_CONTROL))
status = STATE_RUN_FAILED;
}
else
status = STATE_RUN_FAILED;
}
@ -1881,8 +1900,11 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
{
const UINT32 uflags = rdp->finalize_sc_pdus & mask;
if (flags != uflags)
rdp_client_transition_to_state(rdp,
CONNECTION_STATE_FINALIZATION_CLIENT_FONT_MAP);
{
if (!rdp_client_transition_to_state(
rdp, CONNECTION_STATE_FINALIZATION_CLIENT_FONT_MAP))
status = STATE_RUN_FAILED;
}
else
status = STATE_RUN_FAILED;
}
@ -1899,8 +1921,10 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo
WLog_WARN(TAG, "Did not receive a FINALIZE_SC_FONT_MAP_PDU");
{
rdp_client_transition_to_state(rdp, CONNECTION_STATE_ACTIVE);
status = STATE_RUN_ACTIVE;
if (!rdp_client_transition_to_state(rdp, CONNECTION_STATE_ACTIVE))
status = STATE_RUN_FAILED;
else
status = STATE_RUN_ACTIVE;
}
}

View File

@ -355,8 +355,7 @@ BOOL transport_connect_nla(rdpTransport* transport)
return FALSE;
}
rdp_client_transition_to_state(rdp, CONNECTION_STATE_NLA);
return TRUE;
return rdp_client_transition_to_state(rdp, CONNECTION_STATE_NLA);
}
BOOL transport_connect(rdpTransport* transport, const char* hostname, UINT16 port, DWORD timeout)