loader: ignore incomplete relocation entries #406

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

@⁠lordon1a on GitHub · 2026-11-24 02:58 UTC · original
fix/loader-incomplete-relocations → main · +23 −1 · 1 files · 1 commits · closed without merging

AI-assisted.

Problem

In victory_loader::prepare::dir64_relocations, a base relocation block with an odd byte size (block >= 8, e.g. 9) passed block < 8 || at + block > end, causing (at + 8..at + block).step_by(2) to read a 16-bit relocation entry whose second byte lies outside the declared block.

Fix

  • Require block.is_multiple_of(2) alongside block >= 8 and at + block <= end before iterating 16-bit relocation entries.
  • Add unit test prepare::tests::ignores_an_incomplete_relocation_entry verifying that a valid 12-byte block produces the DIR64 entry while a 9-byte block with a trailing incomplete byte is ignored.

Verification

  • cargo xtask policy: 151 files ok
  • cargo test -p victory-loader --lib: 19 passed; 0 failed
  • cargo clippy -p victory-loader --lib --tests -- -D warnings: clean (0 warnings)
**@⁠lordon1a** on GitHub · 2026-11-24 02:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/406) `fix/loader-incomplete-relocations` → `main` · +23 −1 · 1 files · 1 commits · closed without merging AI-assisted. ### Problem In `victory_loader::prepare::dir64_relocations`, a base relocation block with an odd byte size (`block >= 8`, e.g. `9`) passed `block < 8 || at + block > end`, causing `(at + 8..at + block).step_by(2)` to read a 16-bit relocation entry whose second byte lies outside the declared block. ### Fix - Require `block.is_multiple_of(2)` alongside `block >= 8` and `at + block <= end` before iterating 16-bit relocation entries. - Add unit test `prepare::tests::ignores_an_incomplete_relocation_entry` verifying that a valid 12-byte block produces the DIR64 entry while a 9-byte block with a trailing incomplete byte is ignored. ### Verification - `cargo xtask policy`: `151 files ok` - `cargo test -p victory-loader --lib`: `19 passed; 0 failed` - `cargo clippy -p victory-loader --lib --tests -- -D warnings`: clean (0 warnings)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:02:44 +00:00
github-bot closed this pull request 2026-11-26 04:02:44 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 04:34 UTC · original

Thanks @⁠lordon1a for rejecting incomplete DIR64 relocation entries. I tested head b33c704e3335ac2644faafc1ff92bac899e65195 with:

cargo test --locked -p victory-loader --lib ignores_an_incomplete_relocation_entry -- --test-threads=1

Result: 1 passed, 0 failed (18 filtered out). The test checks that a valid 12-byte relocation block retains its DIR64 entry while an odd 9-byte block’s trailing incomplete entry is ignored. This is a synthetic relocation-table parser test, not a title load.

**@⁠jeremygold02** on GitHub · 2026-11-24 04:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/406#issuecomment-7122148390) Thanks @⁠lordon1a for rejecting incomplete DIR64 relocation entries. I tested head `b33c704e3335ac2644faafc1ff92bac899e65195` with: ``` cargo test --locked -p victory-loader --lib ignores_an_incomplete_relocation_entry -- --test-threads=1 ``` Result: 1 passed, 0 failed (18 filtered out). The test checks that a valid 12-byte relocation block retains its DIR64 entry while an odd 9-byte block’s trailing incomplete entry is ignored. This is a synthetic relocation-table parser test, not a title load.

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!406
No description provided.