xnetworking: stop copying struct padding in default_security_info_bytes #75

Merged
certified-retart merged 1 commit from upstream-pr/76 into main 2026-11-23 10:29:17 +00:00
certified-retart commented 2026-11-23 01:17:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by certified-retart on 2026-11-23T01:17:39Z.


Summary

Implements the first change requested in docs/xnetworking-rust-review.md: stop copying uninitialized #[repr(C)] struct padding in default_security_info_bytes.

What changed

  • default_security_info_bytes (crates/xcl/src/hle/xgameruntime/networking.rs):
    • Replaced the unsafe raw struct byte copy (which read uninitialized padding bytes between enabled_http_security_protocol_flags: u32 and thumbprint_count: usize) with a safe zero-initialized Vec<u8> sized to size_of::<XNetworkingSecurityInformation>(), writing DEFAULT_TLS_FLAGS.to_le_bytes() at offset_of!(XNetworkingSecurityInformation, enabled_http_security_protocol_flags).
    • Documented why all-zero bytes represent thumbprint_count == 0, a null thumbprints pointer, and deterministic zero padding on x86_64 Windows.
  • Tests (crates/xcl/src/hle/xgameruntime/networking.rs):
    • Updated security_info_utf8_and_utf16_follow_gdk_arg_order to use storage properly aligned to XNetworkingSecurityInformation (pre-filled with non-zero sentinels 0xAA / 0x55) and assert all three fields (enabled_http_security_protocol_flags, thumbprint_count == 0, thumbprints.is_null()) for both UTF-8 and UTF-16.
    • Added default_security_info_bytes_zeroes_padding_and_fields verifying exact byte length, DEFAULT_TLS_FLAGS at the field offset, and zero bytes everywhere else.
  • Kept async result consumption and TLS verification policy untouched as requested for this first patch.

Verification

  • Target: rustc 1.100.0 (x86_64-pc-windows-msvc), Windows 10 Pro 10.0.19045.
  • cargo test -p xcl --lib hle::xgameruntime::networking: 6 passed, 0 failed.
<!-- greyfinch-sync:ivall/xcl:issue:6550294335 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/76). Originally posted by [certified-retart](https://github.com/certified-retart) on 2026-11-23T01:17:39Z. --- ## Summary Implements the first change requested in [`docs/xnetworking-rust-review.md`](docs/xnetworking-rust-review.md): stop copying uninitialized `#[repr(C)]` struct padding in `default_security_info_bytes`. ### What changed - **`default_security_info_bytes` (`crates/xcl/src/hle/xgameruntime/networking.rs`):** - Replaced the `unsafe` raw struct byte copy (which read uninitialized padding bytes between `enabled_http_security_protocol_flags: u32` and `thumbprint_count: usize`) with a safe zero-initialized `Vec<u8>` sized to `size_of::<XNetworkingSecurityInformation>()`, writing `DEFAULT_TLS_FLAGS.to_le_bytes()` at `offset_of!(XNetworkingSecurityInformation, enabled_http_security_protocol_flags)`. - Documented why all-zero bytes represent `thumbprint_count == 0`, a null `thumbprints` pointer, and deterministic zero padding on x86_64 Windows. - **Tests (`crates/xcl/src/hle/xgameruntime/networking.rs`):** - Updated `security_info_utf8_and_utf16_follow_gdk_arg_order` to use storage properly aligned to `XNetworkingSecurityInformation` (pre-filled with non-zero sentinels `0xAA` / `0x55`) and assert all three fields (`enabled_http_security_protocol_flags`, `thumbprint_count == 0`, `thumbprints.is_null()`) for both UTF-8 and UTF-16. - Added `default_security_info_bytes_zeroes_padding_and_fields` verifying exact byte length, `DEFAULT_TLS_FLAGS` at the field offset, and zero bytes everywhere else. - Kept async result consumption and TLS verification policy untouched as requested for this first patch. ## Verification - Target: `rustc 1.100.0` (`x86_64-pc-windows-msvc`), Windows 10 Pro `10.0.19045`. - `cargo test -p xcl --lib hle::xgameruntime::networking`: **6 passed, 0 failed**.
upstream-sync closed this pull request 2026-11-24 06:57:02 +00:00
ivall commented 2026-11-24 07:00:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T10:29:30Z.


Merged. Tested on Windows 11 with an RX 9070 (RDNA4): cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), also with XCL_SPLIT_WAVE64=1 (the 32-lane split path forced on RDNA). Unicorn Overlord and XDefiant run with this round merged. Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7098054602 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/76#issuecomment-7098054602). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T10:29:30Z. --- Merged. Tested on Windows 11 with an RX 9070 (RDNA4): `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), also with `XCL_SPLIT_WAVE64=1` (the 32-lane split path forced on RDNA). Unicorn Overlord and XDefiant run with this round merged. Thanks!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!75
No description provided.