[core] Improve redirection logging
This commit is contained in:
parent
e66f2f8c75
commit
d4d2b4403c
@ -4331,7 +4331,6 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s)
|
||||
UINT16 length;
|
||||
UINT16 lengthSourceDescriptor;
|
||||
UINT16 lengthCombinedCapabilities;
|
||||
const char* pduName;
|
||||
|
||||
WINPR_ASSERT(rdp);
|
||||
WINPR_ASSERT(rdp->context);
|
||||
@ -4344,12 +4343,8 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s)
|
||||
return TRUE;
|
||||
|
||||
if (!rdp_read_share_control_header(s, NULL, NULL, &pduType, &pduSource))
|
||||
{
|
||||
WLog_ERR(TAG, "rdp_read_share_control_header failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pduName = pdu_type_to_str(pduType);
|
||||
if (pduType == PDU_TYPE_DATA)
|
||||
{
|
||||
/*
|
||||
@ -4366,8 +4361,14 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s)
|
||||
if (pduType != PDU_TYPE_DEMAND_ACTIVE)
|
||||
{
|
||||
if (pduType != PDU_TYPE_SERVER_REDIRECTION)
|
||||
WLog_ERR(TAG, "expected %s %04x, got %04" PRIx16 "", pduName, PDU_TYPE_DEMAND_ACTIVE,
|
||||
pduType);
|
||||
{
|
||||
char buffer1[256] = { 0 };
|
||||
char buffer2[256] = { 0 };
|
||||
|
||||
WLog_ERR(TAG, "[%s] expected %s, got %s", __FUNCTION__,
|
||||
pdu_type_to_str(PDU_TYPE_DEMAND_ACTIVE, buffer1, sizeof(buffer1)),
|
||||
pdu_type_to_str(pduType, buffer2, sizeof(buffer2)));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -4393,9 +4394,12 @@ BOOL rdp_recv_demand_active(rdpRdp* rdp, wStream* s)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!Stream_SafeSeek(s, 4)) /* SessionId */
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
||||
return FALSE;
|
||||
|
||||
UINT32 SessionId = 0;
|
||||
Stream_Read_UINT32(s, SessionId); /* SessionId */
|
||||
|
||||
{
|
||||
rdp_secondary_update_internal* secondary = secondary_update_cast(rdp->update->secondary);
|
||||
secondary->glyph_v2 = (rdp->settings->GlyphSupportLevel > GLYPH_SUPPORT_FULL);
|
||||
|
@ -466,13 +466,14 @@ static state_run_t peer_recv_tpkt_pdu(freerdp_peer* client, wStream* s)
|
||||
|
||||
if (channelId == MCS_GLOBAL_CHANNEL_ID)
|
||||
{
|
||||
char buffer[256] = { 0 };
|
||||
UINT16 pduLength, remain;
|
||||
if (!rdp_read_share_control_header(s, &pduLength, &remain, &pduType, &pduSource))
|
||||
return STATE_RUN_FAILED;
|
||||
|
||||
settings->PduSource = pduSource;
|
||||
|
||||
WLog_DBG(TAG, "Received %s", pdu_type_to_str(pduType));
|
||||
WLog_DBG(TAG, "Received %s", pdu_type_to_str(pduType, buffer, sizeof(buffer)));
|
||||
switch (pduType)
|
||||
{
|
||||
case PDU_TYPE_DATA:
|
||||
|
@ -177,8 +177,8 @@ BOOL rdp_write_security_header(wStream* s, UINT16 flags)
|
||||
BOOL rdp_read_share_control_header(wStream* s, UINT16* tpktLength, UINT16* remainingLength,
|
||||
UINT16* type, UINT16* channel_id)
|
||||
{
|
||||
UINT16 len;
|
||||
UINT16 tmp;
|
||||
UINT16 len = 0;
|
||||
UINT16 tmp = 0;
|
||||
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(type);
|
||||
@ -1390,31 +1390,47 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, UINT16* pLength, UINT16 securityFlags)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const char* pdu_type_to_str(UINT16 pduType)
|
||||
const char* pdu_type_to_str(UINT16 pduType, char* buffer, size_t length)
|
||||
{
|
||||
static char buffer[1024] = { 0 };
|
||||
const char* str;
|
||||
switch (pduType)
|
||||
{
|
||||
case PDU_TYPE_DEMAND_ACTIVE:
|
||||
return "PDU_TYPE_DEMAND_ACTIVE";
|
||||
str = "PDU_TYPE_DEMAND_ACTIVE";
|
||||
break;
|
||||
case PDU_TYPE_CONFIRM_ACTIVE:
|
||||
return "PDU_TYPE_CONFIRM_ACTIVE";
|
||||
str = "PDU_TYPE_CONFIRM_ACTIVE";
|
||||
break;
|
||||
case PDU_TYPE_DEACTIVATE_ALL:
|
||||
return "PDU_TYPE_DEACTIVATE_ALL";
|
||||
str = "PDU_TYPE_DEACTIVATE_ALL";
|
||||
break;
|
||||
case PDU_TYPE_DATA:
|
||||
return "PDU_TYPE_DATA";
|
||||
str = "PDU_TYPE_DATA";
|
||||
break;
|
||||
case PDU_TYPE_SERVER_REDIRECTION:
|
||||
return "PDU_TYPE_SERVER_REDIRECTION";
|
||||
str = "PDU_TYPE_SERVER_REDIRECTION";
|
||||
break;
|
||||
case PDU_TYPE_FLOW_TEST:
|
||||
return "PDU_TYPE_FLOW_TEST";
|
||||
str = "PDU_TYPE_FLOW_TEST";
|
||||
break;
|
||||
case PDU_TYPE_FLOW_RESPONSE:
|
||||
return "PDU_TYPE_FLOW_RESPONSE";
|
||||
str = "PDU_TYPE_FLOW_RESPONSE";
|
||||
break;
|
||||
case PDU_TYPE_FLOW_STOP:
|
||||
return "PDU_TYPE_FLOW_STOP";
|
||||
str = "PDU_TYPE_FLOW_STOP";
|
||||
break;
|
||||
default:
|
||||
_snprintf(buffer, sizeof(buffer), "UNKNOWN %04" PRIx16, pduType);
|
||||
return buffer;
|
||||
str = "PRU_TYPE_UNKNOWN";
|
||||
break;
|
||||
}
|
||||
|
||||
winpr_str_append(str, buffer, length, "");
|
||||
{
|
||||
char msg[32] = { 0 };
|
||||
_snprintf(msg, sizeof(msg), "[0x%08" PRIx32 "]", pduType);
|
||||
winpr_str_append(msg, buffer, length, "");
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1492,10 +1508,7 @@ static state_run_t rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
|
||||
UINT16 remain;
|
||||
|
||||
if (!rdp_read_share_control_header(s, NULL, &remain, &pduType, &pduSource))
|
||||
{
|
||||
WLog_ERR(TAG, "rdp_recv_tpkt_pdu: rdp_read_share_control_header() fail");
|
||||
return STATE_RUN_FAILED;
|
||||
}
|
||||
|
||||
sub = Stream_StaticInit(&subbuffer, Stream_Pointer(s), remain);
|
||||
if (!Stream_SafeSeek(s, remain))
|
||||
@ -1534,17 +1547,22 @@ static state_run_t rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s)
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(TAG, "incorrect PDU type: 0x%04" PRIX16 "", pduType);
|
||||
break;
|
||||
{
|
||||
char buffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "incorrect PDU type: %s",
|
||||
pdu_type_to_str(pduType, buffer, sizeof(buffer)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
diff = Stream_GetRemainingLength(sub);
|
||||
if (diff > 0)
|
||||
{
|
||||
char buffer[256] = { 0 };
|
||||
WLog_WARN(TAG,
|
||||
"pduType %s not properly parsed, %" PRIdz
|
||||
" bytes remaining unhandled. Skipping.",
|
||||
pdu_type_to_str(pduType), diff);
|
||||
pdu_type_to_str(pduType, buffer, sizeof(buffer)), diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ FREERDP_LOCAL void* rdp_get_io_callback_context(rdpRdp* rdp);
|
||||
#endif
|
||||
|
||||
const char* data_pdu_type_to_string(UINT8 type);
|
||||
const char* pdu_type_to_str(UINT16 pduType);
|
||||
const char* pdu_type_to_str(UINT16 pduType, char* buffer, size_t length);
|
||||
|
||||
BOOL rdp_finalize_reset_flags(rdpRdp* rdp, BOOL clearAll);
|
||||
BOOL rdp_finalize_set_flag(rdpRdp* rdp, UINT32 flag);
|
||||
|
@ -369,11 +369,11 @@ static state_run_t rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
|
||||
Stream_Read_UINT16(s, length); /* length (2 bytes) */
|
||||
Stream_Read_UINT32(s, redirection->sessionID); /* sessionID (4 bytes) */
|
||||
Stream_Read_UINT32(s, redirection->flags); /* redirFlags (4 bytes) */
|
||||
WLog_VRB(TAG,
|
||||
"flags: 0x%04" PRIX16 ", redirFlags: %s [0x%08" PRIX32 "] length: %" PRIu16
|
||||
", sessionID: 0x%08" PRIX32 "",
|
||||
flags, rdp_redirection_flags_to_string(redirection->flags, buffer, sizeof(buffer)),
|
||||
redirection->flags, length, redirection->sessionID);
|
||||
WLog_INFO(TAG,
|
||||
"flags: 0x%04" PRIX16 ", redirFlags: %s [0x%08" PRIX32 "] length: %" PRIu16
|
||||
", sessionID: 0x%08" PRIX32 "",
|
||||
flags, rdp_redirection_flags_to_string(redirection->flags, buffer, sizeof(buffer)),
|
||||
redirection->flags, length, redirection->sessionID);
|
||||
|
||||
/* Although MS-RDPBCGR does not mention any length constraints limits for the
|
||||
* variable length null-terminated unicode strings in the RDP_SERVER_REDIRECTION_PACKET
|
||||
|
Loading…
Reference in New Issue
Block a user