Skip to content

fix(pdu): correct ShareDataHeader uncompressedLength calculation#1148

Merged
Benoît Cortier (CBenoit) merged 1 commit intoDevolutions:masterfrom
lamco-admin:fix/share-data-uncompressed-length
Mar 5, 2026
Merged

fix(pdu): correct ShareDataHeader uncompressedLength calculation#1148
Benoît Cortier (CBenoit) merged 1 commit intoDevolutions:masterfrom
lamco-admin:fix/share-data-uncompressed-length

Conversation

@glamberson
Copy link
Contributor

Summary

ShareDataHeader::encode() was calculating uncompressedLength as
payload_size + 4 (adding pduType2, compressedType, and compressedLength
field sizes). Per MS-RDPBCGR 2.2.8.1.1.1.2, this field should contain
only the uncompressed payload size.

Vladyslav Nikonov (@pacmancoder) confirmed this as a bug in May 2024
(#447 (comment)):
"pretty sure this is a bug on our side"

FreeRDP encodes only the payload size. Servers tolerate both values since
the decode path does not validate uncompressedLength against actual
payload size, but the current encoding does not match the spec.

Changes

File Change
ironrdp-pdu/src/rdp/headers.rs Remove extra field sizes from uncompressedLength
ironrdp-testsuite-core/src/rdp.rs Update 7 byte buffer fixtures to match corrected encoding

Verification

cargo xtask check fmt, cargo xtask check lints, and cargo xtask check tests all pass.

Fixes part of #447

The uncompressedLength field in ShareDataHeader::encode() included
the sizes of pduType2, compressedType, and compressedLength fields
(4 extra bytes) on top of the actual PDU payload size.

Per MS-RDPBCGR 2.2.8.1.1.1.2, uncompressedLength should contain
only the payload size. This matches FreeRDP's implementation.

pacmancoder confirmed this as a bug in May 2024:
Devolutions#447 (comment)

Fixes part of Devolutions#447
Copy link
Member

@CBenoit Benoît Cortier (CBenoit) left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@CBenoit Benoît Cortier (CBenoit) merged commit c2688f4 into Devolutions:master Mar 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants