HLE: validate null pointer in ApuIsVirtualAddressValid and overflow in ApuAlloc #528

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

@⁠pushkarreddyy on GitHub · 2026-11-24 04:28 UTC · original
pushkarreddyy:fix/audio-apu-validation → main · +23 −5 · 1 files · 1 commits · closed without merging

Problem

In crates/victory-hle/src/modules/audio.rs:

  • ApuIsVirtualAddressValid does not short-circuit on null pointers before calling heap_map(0).
  • ApuMapVirtualAddress does not check for null input.
  • ApuAlloc does not check for arithmetic overflow when validating size and align.

Fix

  • Immediately return false if ptr.is_null() in ApuIsVirtualAddressValid.
  • Immediately return 0 if ptr.is_null() in ApuMapVirtualAddress.
  • Reject integer overflow via size.checked_add(align).is_none() in ApuAlloc.
  • Added unit test coverage for null pointer guards and overflow validation.

No game files used.

**@⁠pushkarreddyy** on GitHub · 2026-11-24 04:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/528) `pushkarreddyy:fix/audio-apu-validation` → `main` · +23 −5 · 1 files · 1 commits · closed without merging ## Problem In `crates/victory-hle/src/modules/audio.rs`: - `ApuIsVirtualAddressValid` does not short-circuit on null pointers before calling `heap_map(0)`. - `ApuMapVirtualAddress` does not check for null input. - `ApuAlloc` does not check for arithmetic overflow when validating `size` and `align`. ## Fix - Immediately return `false` if `ptr.is_null()` in `ApuIsVirtualAddressValid`. - Immediately return `0` if `ptr.is_null()` in `ApuMapVirtualAddress`. - Reject integer overflow via `size.checked_add(align).is_none()` in `ApuAlloc`. - Added unit test coverage for null pointer guards and overflow validation. No game files used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:07:14 +00:00
github-bot closed this pull request 2026-11-26 04:07:14 +00:00
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 04:51 UTC · original

### Technical Verification & Implementation Details

Context & Root Cause

In crates/victory-hle/src/modules/audio.rs:

  1. ApuIsVirtualAddressValid called heap_map(0) when passed null pointers instead of short-circuiting to false.
  2. ApuMapVirtualAddress did not check for null pointer input.
  3. ApuAlloc performed unbounded arithmetic size + align without overflow checks.

Changes & Diff

  • Return 0 (false) immediately if ptr.is_null() in ApuIsVirtualAddressValid.
  • Return 0 immediately if ptr.is_null() in ApuMapVirtualAddress.
  • Enforced overflow check size.checked_add(align).is_none() in ApuAlloc.
  • Added unit test suite covering null handling and overflow protection.

Git Log Line & Verification

ext b1539b7 HLE: validate null pointer in ApuIsVirtualAddressValid and overflow in ApuAlloc crates/victory-hle/src/modules/audio.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)

  • Passes cargo xtask policy (Rule #1 compliance, zero game assets).
  • Formatted with rustfmt --edition 2024.
**@⁠pushkarreddyy** on GitHub · 2026-11-24 04:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/528#issuecomment-7122399751) ### Technical Verification & Implementation Details #### Context & Root Cause In `crates/victory-hle/src/modules/audio.rs`: 1. `ApuIsVirtualAddressValid` called `heap_map(0)` when passed null pointers instead of short-circuiting to `false`. 2. `ApuMapVirtualAddress` did not check for null pointer input. 3. `ApuAlloc` performed unbounded arithmetic `size + align` without overflow checks. #### Changes & Diff - Return `0` (false) immediately if `ptr.is_null()` in `ApuIsVirtualAddressValid`. - Return `0` immediately if `ptr.is_null()` in `ApuMapVirtualAddress`. - Enforced overflow check `size.checked_add(align).is_none()` in `ApuAlloc`. - Added unit test suite covering null handling and overflow protection. #### Git Log Line & Verification ` ext b1539b7 HLE: validate null pointer in ApuIsVirtualAddressValid and overflow in ApuAlloc crates/victory-hle/src/modules/audio.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) ` - Passes `cargo xtask policy` (Rule #1 compliance, zero game assets). - Formatted with `rustfmt --edition 2024`.
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 06:15 UTC · original

Thank you @⁠LAKSHYA-cmd-tech for testing and verifying on Windows 11! Glad all 87 tests and asset policy passed cleanly.

**@⁠pushkarreddyy** on GitHub · 2026-11-24 06:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/528#issuecomment-7123739312) Thank you @⁠LAKSHYA-cmd-tech for testing and verifying on Windows 11! Glad all 87 tests and asset policy passed cleanly.
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 06:23 UTC · original

### Ready for Merge
Verified and approved on Windows 11 by @⁠LAKSHYA-cmd-tech (all unit tests passing, zero Clippy warnings, asset policy passing).

@⁠Marvisak: Ready for maintainer review and merge when you have time!

**@⁠pushkarreddyy** on GitHub · 2026-11-24 06:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/528#issuecomment-7123887269) ### Ready for Merge Verified and approved on Windows 11 by @⁠LAKSHYA-cmd-tech (all unit tests passing, zero Clippy warnings, asset policy passing). @⁠Marvisak: Ready for maintainer review and merge when you have time!
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 12:38 UTC · original

Thank you @⁠mercuryVM for testing and approving!

Acknowledged on keeping functional diffs strictly separated from formatting hunks—I'll ensure future HLE PRs isolate formatting into dedicated commits for maximum review clarity.

**@⁠pushkarreddyy** on GitHub · 2026-11-24 12:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/528#issuecomment-7131717250) Thank you @⁠mercuryVM for testing and approving! Acknowledged on keeping functional diffs strictly separated from formatting hunks—I'll ensure future HLE PRs isolate formatting into dedicated commits for maximum review clarity.
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 13:01 UTC · original

@⁠Marvisak: PR #528 has approvals from both @⁠LAKSHYA-cmd-tech and @⁠mercuryVM (verified clean on Windows 11 MSVC with all 87 HLE tests passing and Rule #1 compliant). Whenever you have a moment, this is ready to merge!

**@⁠pushkarreddyy** on GitHub · 2026-11-24 13:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/528#issuecomment-7132250124) @⁠Marvisak: PR #528 has approvals from both @⁠LAKSHYA-cmd-tech and @⁠mercuryVM (verified clean on Windows 11 MSVC with all 87 HLE tests passing and Rule #1 compliant). Whenever you have a moment, this is ready to merge!
Author
Owner

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

Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current).

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:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/528#issuecomment-7148096518) Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current). 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!528
No description provided.