xnetworking: stop copying struct padding in default_security_info_bytes #76

Manually merged
github merged 1 commit from gh-pr/76/head into gh-pr/76/base 2026-11-26 04:08:16 +00:00
Owner

@⁠certified-retart on GitHub · 2026-11-23 01:17 UTC · original
certified-retart:fix/xnetworking-security-info-padding → main · +33 −16 · 1 files · 1 commits · merged 2026-11-23 10:29 UTC

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.
**@⁠certified-retart** on GitHub · 2026-11-23 01:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/76) `certified-retart:fix/xnetworking-security-info-padding` → `main` · +33 −16 · 1 files · 1 commits · merged 2026-11-23 10:29 UTC ## 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**.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:08:13 +00:00
github manually merged commit 9a85c6eb6b into gh-pr/76/base 2026-11-26 04:08:16 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 10:29 UTC · original

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!

**@⁠ivall** on GitHub · 2026-11-23 10:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/76#issuecomment-7098054602) 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!
This discussion has been locked. Commenting is limited to contributors.
No description provided.