HLE audio capture: fix WAV/QPC overflows, chunk silence writes, close target handle #1309

Closed
github-bot wants to merge 1 commit from gh-pr/1309/head into gh-pr/1309/base
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:18 UTC · original
geiyiliyabumo:test/hle-audio-capture-audit → main · +157 −17 · 1 files · 1 commits · closed without merging

Summary

Audits \crates/victory-hle/src/modules/audio/capture.rs\ (previously 0 tests) and fixes five bugs:

  • Clamps \header(frames)\ data length at \u32::MAX - 36\ with saturating \u64\ multiplication so \36 + data\ can never overflow \u32\ when \ rames * 4\ is near \u32::MAX.
  • Handles retrograde QPC timestamps, \AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR, and large \delta * RATE\ values via \saturating_sub\ and \u128\ math instead of panicking/underflowing.
  • Streams silence gaps and silent packets from a fixed 4 KiB stack buffer instead of allocating a single unbounded \Vec\ for long silence stretches.
  • Avoids \slice::from_raw_parts\ UB when \ rames == 0\ or \data.is_null(), wraps the opened target process handle in an RAII \CloseHandle\ guard, exits activation polling if the target exits early, and ignores empty \VICTORY_AUDIO_CAPTURE="".
  • Adds 6 deterministic synthetic unit tests under --features diagnostics.

Verification

  • \cargo test -p victory-hle --features diagnostics --lib modules::audio::capture\ ? 6 passed, 0 failed
  • \cargo clippy -p victory-hle --all-targets --features diagnostics -- -D warnings\ ? clean
  • \cargo xtask policy\ ? 154 files ok

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1309) `geiyiliyabumo:test/hle-audio-capture-audit` → `main` · +157 −17 · 1 files · 1 commits · closed without merging ## Summary Audits \crates/victory-hle/src/modules/audio/capture.rs\ (previously 0 tests) and fixes five bugs: - Clamps \header(frames)\ data length at \u32::MAX - 36\ with saturating \u64\ multiplication so \36 + data\ can never overflow \u32\ when \ rames * 4\ is near \u32::MAX\. - Handles retrograde QPC timestamps, \AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR\, and large \delta * RATE\ values via \saturating_sub\ and \u128\ math instead of panicking/underflowing. - Streams silence gaps and silent packets from a fixed 4 KiB stack buffer instead of allocating a single unbounded \Vec\ for long silence stretches. - Avoids \slice::from_raw_parts\ UB when \ rames == 0\ or \data.is_null()\, wraps the opened target process handle in an RAII \CloseHandle\ guard, exits activation polling if the target exits early, and ignores empty \VICTORY_AUDIO_CAPTURE=""\. - Adds 6 deterministic synthetic unit tests under \--features diagnostics\. ## Verification - \cargo test -p victory-hle --features diagnostics --lib modules::audio::capture\ ? 6 passed, 0 failed - \cargo clippy -p victory-hle --all-targets --features diagnostics -- -D warnings\ ? clean - \cargo xtask policy\ ? 154 files ok *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:06 +00:00
github-bot closed this pull request 2026-11-26 04:27:06 +00:00
Author
Owner

@⁠muhammed-aksoy on GitHub · 2026-11-24 17:54 UTC · original

I tested 0e8c0eb on Windows against ffe310e. The HLE package passed 95 tests. In a local batch with #1279, #1283, #1307, and #1311, the all-features Windows workspace suite passed 360 tests with six ignored and zero failures. Clippy with warnings denied and asset policy passed at batch commit 1409f9c. WARP was selected for the GPU tests. AI-assisted.

**@⁠muhammed-aksoy** on GitHub · 2026-11-24 17:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1309#issuecomment-7139872856) I tested `0e8c0eb` on Windows against `ffe310e`. The HLE package passed 95 tests. In a local batch with #1279, #1283, #1307, and #1311, the all-features Windows workspace suite passed 360 tests with six ignored and zero failures. Clippy with warnings denied and asset policy passed at batch commit `1409f9c`. WARP was selected for the GPU tests. AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:37 UTC · original

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #478. The same four capture.rs hardenings as the earlier and smaller #478, plus a process-handle guard and an empty-variable check of no practical effect (the recorder process exits when done).

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1309#issuecomment-7148702224) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #478. The same four capture.rs hardenings as the earlier and smaller #478, plus a process-handle guard and an empty-variable check of no practical effect (the recorder process exits when done). If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1309
No description provided.