fix(session): Fix bitmap stride mismatch and out-of-bounds writes for xRDP compatibility#1252
Open
Amartya Anshuman (amartyaa) wants to merge 1 commit intoDevolutions:masterfrom
Open
fix(session): Fix bitmap stride mismatch and out-of-bounds writes for xRDP compatibility#1252Amartya Anshuman (amartyaa) wants to merge 1 commit intoDevolutions:masterfrom
Amartya Anshuman (amartyaa) wants to merge 1 commit intoDevolutions:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1251
Summary
This PR fixes two related issues in
ironrdp-sessionthat cause diagonal bitmap distortion and index-out-of-bounds panics when connecting to xRDP servers.Changes
crates/ironrdp-session/src/fast_path.rsxRDP sends bitmap updates where the data dimensions (
update.width×update.height) differ from the destination rectangle (update.rectangle). Per MS-RDPBCGR §2.2.9.1.1.3.1.2.2,bitmapWidth/bitmapHeightdefine the pixel data layout whiledestLeft/destTop/destRight/destBottomdefine the screen placement.The
apply_*methods use the rectangle's width as the row stride. Passingupdate.rectanglewhen it's wider/narrower than the actual data causes diagonal shearing.Fix: Construct a
blit_rectwhose dimensions match the actual bitmap data, positioned at the destination's top-left corner:crates/ironrdp-session/src/image.rsAdded bounds checks to all apply_* bitmap methods that were missing them:
Each pixel write is now guarded with
if dst_idx + bytes_per_pixel < self.data.len().This is consistent with how other parts of the codebase handle edge-of-framebuffer updates — pixels beyond the buffer are silently clipped rather than panicking.
Also added a
max_rowsclamp inapply_rgb24_iterto prevent iterating beyond the framebuffer height.Testing