Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,12 @@ impl<'de> Decode<'de> for Codec {
match guid {
GUID_REMOTEFX => CodecProperty::RemoteFx(property),
GUID_IMAGE_REMOTEFX => CodecProperty::ImageRemoteFx(property),
_ => unreachable!(),
// `guid` is validated as RemoteFX or ImageRemoteFX by the outer
// match arm, so the `_` branch is genuinely dead. Keep it as a
// redundant correctness check that fires loudly under tests and
// fuzzing if a future change to the outer arm breaks that
// invariant. Not reachable from the wire.
_ => unreachable!("guid validated as RemoteFX or ImageRemoteFX by the outer match"),
}
}
GUID_IGNORE => CodecProperty::Ignore,
Expand Down
29 changes: 28 additions & 1 deletion crates/ironrdp-pdu/src/rdp/capability_sets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,34 @@ impl Encode for CapabilitySet {
CapabilitySet::Rail(buffer) => (CapabilitySetType::Rail, buffer),
CapabilitySet::WindowList(buffer) => (CapabilitySetType::WindowList, buffer),
CapabilitySet::BitmapCacheV3(buffer) => (CapabilitySetType::BitmapCacheV3CodecID, buffer),
_ => unreachable!(),
// Structured variants are routed through the outer match's
// specific arms above this block and cannot reach this
// inner match. Listing them explicitly (instead of using
// `_ =>`) makes a future addition to `CapabilitySet` a
// compile error here until the new variant is routed in
// this `Encode` impl. PR #1313 (BitmapCacheV3 encoder
// `unreachable!()` reached on decoder-accepted input)
// demonstrated why a runtime catch-all is the wrong shape
// for this match.
CapabilitySet::General(_)
| CapabilitySet::Bitmap(_)
| CapabilitySet::Order(_)
| CapabilitySet::BitmapCache(_)
| CapabilitySet::BitmapCacheRev2(_)
| CapabilitySet::Pointer(_)
| CapabilitySet::Sound(_)
| CapabilitySet::Input(_)
| CapabilitySet::Brush(_)
| CapabilitySet::GlyphCache(_)
| CapabilitySet::OffscreenBitmapCache(_)
| CapabilitySet::VirtualChannel(_)
| CapabilitySet::MultiFragmentUpdate(_)
| CapabilitySet::LargePointer(_)
| CapabilitySet::SurfaceCommands(_)
| CapabilitySet::BitmapCodecs(_)
| CapabilitySet::FrameAcknowledge(_) => {
unreachable!("structured variant routed to raw-buffer encoder arm")
}
};

dst.write_u16(capability_set_type.as_u16());
Expand Down
Loading