fix: correct UTF-16 string length computations#1161
fix: correct UTF-16 string length computations#1161Benoît Cortier (CBenoit) wants to merge 7 commits intomasterfrom
Conversation
Replace legacy string helpers in ironrdp-pdu (to_utf16_bytes, from_utf16_bytes, encode_string, decode_string, etc.) with typed primitives from the ironrdp-str crate:
|
Coverage Report 🤖 ⚙️Past: New: Diff: +0.14% [this comment will be updated automatically] |
There was a problem hiding this comment.
Pull request overview
This PR replaces several ad-hoc UTF-16/ANSI string helpers in ironrdp-pdu (and related crates) with typed wire-string primitives from ironrdp-str, aiming to fix incorrect UTF-16 length computations (Issue #130) and improve decode performance via lazy validation.
Changes:
- Migrate multiple protocol fields from
String+ legacy helpers toironrdp-strtyped primitives (FixedString,CchString,CbU32String*) for correct UTF-16 sizing and null-terminator handling. - Introduce
ironrdp_str::ansifree functions for UTF-8/ANSI wire string decode/encode/length computations. - Update tests, fixtures, and crate dependencies across the workspace to use the new string representations.
Reviewed changes
Copilot reviewed 36 out of 37 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/ironrdp-testsuite-core/tests/pcb.rs | Updates PCB tests to use CchString for v2 payloads. |
| crates/ironrdp-testsuite-core/tests/clipboard/mod.rs | Adjusts expected clipboard file list debug output for FixedString<260>. |
| crates/ironrdp-testsuite-core/src/core_data.rs | Switches core data fixtures to FixedString fields. |
| crates/ironrdp-testsuite-core/src/client_info.rs | Switches timezone name fixtures to FixedString<32>. |
| crates/ironrdp-testsuite-core/Cargo.toml | Adds dependency on ironrdp-str. |
| crates/ironrdp-str/src/prefixed.rs | Adds CbU32StringNoNull alias for u32 byte-prefixed, non-null-terminated UTF-16 strings. |
| crates/ironrdp-str/src/lib.rs | Exposes new ansi module behind alloc. |
| crates/ironrdp-str/src/ansi.rs | Adds ANSI (UTF-8) decode/encode and length helpers. |
| crates/ironrdp-str/Cargo.toml | Disables lib tests/doctests for the crate. |
| crates/ironrdp-server/src/capabilities.rs | Updates input capability construction to use FixedString IME filename. |
| crates/ironrdp-server/Cargo.toml | Adds dependency on ironrdp-str. |
| crates/ironrdp-rdpdr/src/pdu/efs.rs | Changes FileRenameInformation filename handling to a prefixed string type. |
| crates/ironrdp-rdpdr/Cargo.toml | Adds dependency on ironrdp-str. |
| crates/ironrdp-pdu/src/utf16.rs | Removes legacy UTF-16 helper module. |
| crates/ironrdp-pdu/src/rdp/server_license/server_upgrade_license/tests.rs | Updates license upgrade tests to use CbU32StringNullIncluded. |
| crates/ironrdp-pdu/src/rdp/server_license/server_upgrade_license/mod.rs | Reworks license info encoding/decoding with ansi + prefixed UTF-16 string types. |
| crates/ironrdp-pdu/src/rdp/server_license/server_license_request/tests.rs | Updates license request tests to use CbU32StringNullIncluded. |
| crates/ironrdp-pdu/src/rdp/server_license/server_license_request/mod.rs | Reworks product info and scope strings using ansi + prefixed UTF-16 string types. |
| crates/ironrdp-pdu/src/rdp/server_license/mod.rs | Removes UTF-8/UTF-16 null terminator size constants no longer needed. |
| crates/ironrdp-pdu/src/rdp/server_license/client_new_license_request/tests.rs | Updates size computations and product info test data to new string helpers/types. |
| crates/ironrdp-pdu/src/rdp/server_license/client_new_license_request/mod.rs | Switches username/machine-name blob string handling to ansi helpers. |
| crates/ironrdp-pdu/src/rdp/client_info.rs | Switches timezone names to FixedString<32> and uses typed decode/encode. |
| crates/ironrdp-pdu/src/rdp/capability_sets/mod.rs | Uses ansi::decode_ansi for Demand Active source descriptor decoding. |
| crates/ironrdp-pdu/src/rdp/capability_sets/input/tests.rs | Updates input capability tests for FixedString IME filename. |
| crates/ironrdp-pdu/src/rdp/capability_sets/input.rs | Switches IME filename to FixedString<32> and typed decode/encode. |
| crates/ironrdp-pdu/src/pcb.rs | Reworks PCB v2 payload to CchString and updates size/encode/decode accordingly. |
| crates/ironrdp-pdu/src/lib.rs | Stops exporting removed utf16 module. |
| crates/ironrdp-pdu/src/gcc/core_data/client.rs | Switches core data fixed-size string fields to FixedString types. |
| crates/ironrdp-pdu/Cargo.toml | Adds dependency on ironrdp-str. |
| crates/ironrdp-dvc/src/pdu.rs | Switches DRDYNVC channel name parsing/encoding to ansi helpers. |
| crates/ironrdp-dvc/Cargo.toml | Adds dependency on ironrdp-str. |
| crates/ironrdp-connector/src/connection_activation.rs | Constructs FixedString IME filename using truncating helper. |
| crates/ironrdp-connector/src/connection.rs | Constructs FixedString client/IME/product ID fields using truncating helper. |
| crates/ironrdp-connector/Cargo.toml | Adds dependency on ironrdp-str. |
| crates/ironrdp-cliprdr/src/pdu/format_data/file_list.rs | Switches file descriptor name field to FixedString<260> and typed decode/encode. |
| crates/ironrdp-cliprdr/Cargo.toml | Adds dependency on ironrdp-str. |
| Cargo.lock | Records new workspace dependency edges on ironrdp-str. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
crates/ironrdp-pdu/src/rdp/server_license/server_license_request/mod.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 38 out of 40 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
crates/ironrdp-pdu/src/rdp/server_license/server_license_request/mod.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 38 out of 40 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Replace legacy string helpers in ironrdp-pdu (to_utf16_bytes, from_utf16_bytes, encode_string, decode_string, etc.) with typed primitives from the ironrdp-str crate.
This is both improving the correctness of UTF-16 string handling, and improving the performance of decoding because ironrdp-str primitives are lazily-validated as opposed to the previously eagerly-validated logic.
Fixes #130