Repository navigation
fix(pdu): check remaining length when skipping padding and reading client core data #2130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Marc-André Moreau (mamoreau-devolutions)
merged 3 commits into
Devolutions:master
from
se-wo:fix/decode-bounds-checks
Oct 24, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| use expect_test::expect; | ||
| use ironrdp_core::{DecodeResult, ReadCursor, read_padding}; | ||
|
|
||
| #[test] | ||
| fn read_padding_macro_returns_error_on_truncated_input() { | ||
| fn decode_with_trailing_padding(src: &mut ReadCursor<'_>) -> DecodeResult<u8> { | ||
| let value = src.read_u8(); | ||
| read_padding!(src, 4); | ||
| Ok(value) | ||
| } | ||
|
|
||
| let mut src = ReadCursor::new(&[1, 0, 0, 0]); | ||
|
|
||
| let e = decode_with_trailing_padding(&mut src).unwrap_err(); | ||
|
|
||
| assert_eq!(src.pos(), 1); | ||
| assert_eq!(src.len(), 3); | ||
| expect![[r#" | ||
| Error { | ||
| context: "integration_tests_core::padding::read_padding_macro_returns_error_on_truncated_input::decode_with_trailing_padding", | ||
| kind: NotEnoughBytes { | ||
| received: 3, | ||
| expected: 4, | ||
| offset: Some( | ||
| 1, | ||
| ), | ||
| }, | ||
| source: None, | ||
| } | ||
| "#]] | ||
| .assert_debug_eq(&e); | ||
| } | ||
|
|
||
| #[test] | ||
| #[cfg(debug_assertions)] | ||
| #[should_panic(expected = "advancing past the end of the buffer")] | ||
| fn read_cursor_advance_past_end_is_caught_in_debug_builds() { | ||
| let mut src = ReadCursor::new(&[0, 0]); | ||
|
|
||
| src.advance(3); | ||
| } | ||
|
|
||
| /// Release builds have no debug assertion: an overrun cursor reads as empty instead of overflowing. | ||
| #[test] | ||
| #[cfg(not(debug_assertions))] | ||
| fn read_cursor_len_saturates_when_advanced_past_end() { | ||
| let mut src = ReadCursor::new(&[0, 0]); | ||
|
|
||
| src.advance(3); | ||
|
|
||
| assert_eq!(src.len(), 0); | ||
| assert!(src.is_empty()); | ||
| assert!(src.remaining().is_empty()); | ||
| assert!(src.try_read_u8().is_err()); | ||
| } |
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[skeptical] read_padding! now requires the enclosing function to return a decode Result, making the PR's 'no public API change' claim incomplete — low 🟡 — read_padding! is #[macro_export] and its new expansion performs ensure_size! followed by an early Err return, so enclosing functions not returning a Result compatible with ironrdp_core::Error no longer compile; previously the macro advanced the cursor in any context. cargo-semver-checks cannot detect macro semantic changes, so the PR body's compatibility claim overstates safety for downstream users. The change is intentional, documented, and mirrors ensure_size!'s existing requirement, so it is a documentation/communication gap rather than a code defect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, the compatibility note was overstated. 32e840e documents on read_padding! that, like ensure_size!, it must be used in a function returning Result<_, DecodeError>, and the PR description now states this contract change explicitly. All workspace uses already satisfy it.