Skip to content

Commit 78effb3

Browse files
authored
fix(connector): surface actual PDU type when an unexpected Share Control PDU arrives (#1236)
1 parent 1a09dba commit 78effb3

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

crates/ironrdp-connector/src/connection_activation.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use ironrdp_pdu::rdp::capability_sets::CapabilitySet;
55
use tracing::{debug, warn};
66

77
use crate::{
8-
Config, ConnectionFinalizationSequence, ConnectorResult, DesktopSize, Sequence, State, Written, general_err, legacy,
8+
Config, ConnectionFinalizationSequence, ConnectorResult, DesktopSize, Sequence, State, Written, general_err,
9+
legacy, reason_err,
910
};
1011

1112
/// Represents the Capability Exchange and Connection Finalization phases
@@ -122,8 +123,10 @@ impl Sequence for ConnectionActivationSequence {
122123
{
123124
server_demand_active.pdu.capability_sets
124125
} else {
125-
return Err(general_err!(
126-
"unexpected Share Control Pdu (expected ServerDemandActive)",
126+
return Err(reason_err!(
127+
"ConnectionActivation::CapabilitiesExchange",
128+
"unexpected Share Control PDU during capabilities exchange: got {} (expected Server Demand Active PDU)",
129+
share_control_ctx.pdu.as_short_name(),
127130
));
128131
};
129132

crates/ironrdp-connector/src/legacy.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ironrdp_pdu::rdp::headers::{BASIC_SECURITY_HEADER_SIZE, BasicSecurityHeaderF
66
use ironrdp_pdu::rdp::multitransport::MultitransportRequestPdu;
77
use ironrdp_pdu::x224::X224;
88

9-
use crate::{ConnectorError, ConnectorErrorExt as _, ConnectorResult, general_err, reason_err};
9+
use crate::{ConnectorError, ConnectorErrorExt as _, ConnectorResult, reason_err};
1010

1111
pub fn encode_send_data_request<T>(
1212
initiator_id: u16,
@@ -149,8 +149,10 @@ pub fn decode_share_data(ctx: SendDataIndicationCtx<'_>) -> ConnectorResult<Shar
149149
let ctx = decode_share_control(ctx)?;
150150

151151
let rdp::headers::ShareControlPdu::Data(share_data_header) = ctx.pdu else {
152-
return Err(general_err!(
153-
"received unexpected Share Control Pdu (expected Share Data Header)"
152+
return Err(reason_err!(
153+
"decode_share_data",
154+
"received unexpected Share Control PDU: got {} (expected Data PDU)",
155+
ctx.pdu.as_short_name(),
154156
));
155157
};
156158

@@ -210,8 +212,10 @@ pub fn decode_io_channel(ctx: SendDataIndicationCtx<'_>) -> ConnectorResult<IoCh
210212

211213
Ok(IoChannelPdu::Data(share_data_ctx))
212214
}
213-
_ => Err(general_err!(
214-
"received unexpected Share Control Pdu (expected Share Data Header or Server Deactivate All)"
215+
other => Err(reason_err!(
216+
"decode_io_channel",
217+
"received unexpected Share Control PDU: got {} (expected Data PDU or Server Deactivate All PDU)",
218+
other.as_short_name(),
215219
)),
216220
}
217221
}

0 commit comments

Comments
 (0)