Honor ADAT extent limits and validate headers before table reads #3

Open
github-bot wants to merge 1 commit from github-bot/gh-3 into main AGit
Owner

@⁠yefan911 on GitHub · 2026-11-26 18:18 UTC · original
yefan911:fix/adat-parser-bounds → main · +161 −4 · 3 files · 1 commits · open

extent_bank(..., limit=...) checks the caller's extent limit for computed chunk tables, but both suffix-scan paths return their recovered extent without that check. A generated bank declaring a bank-relative extent of 0x1800 is accepted with limit=0x1000 for flags 0xff25 and 0xff61, and for the fallback layouts of 0xff21 and 0xff02.

Apply the same limit check to the recovered table's maximum extent. Reject the whole bank when it exceeds the limit, preserving the longest-table selection and existing alignment behavior.

Also move count validation before table dispatch and before the legacy info-table read, and reject header regions outside the caller's limit or MAX_BANK before following them. Previously, scanned variants accepted zero or excessive stream counts, and a malformed header could cause a large read request before rejection.

Seven tests use generated in-memory headers and a recording reader to cover all computed/scanned/fallback table paths, out-of-limit records before a valid final suffix, exact-limit extents at nonzero file offsets, invalid counts, oversized header reads, and valid legacy counts including MAX_STREAMS. The new rejection regressions fail on the original implementation.

Validation with Python 3.13.5 on Windows:

  • python tests/test_adat_bounds.py — 7 tests pass.
  • python tests/test_extraction_tools.py — PASS.
  • python tests/test_robustness.py --rounds 200 — PASS (231 generated inputs).
  • git diff --check — clean.

This is independent of #2 and targets parser validation rather than candidate scanning. All fixtures are generated synthetic bytes; no GTA VI archives, executables, assets, dumps, or private SDK material were accessed or included. No game-runtime validation is claimed.

**@⁠yefan911** on GitHub · 2026-11-26 18:18 UTC · [original](https://github.com/lynxnathan/rage-tools-vi/pull/3) `yefan911:fix/adat-parser-bounds` → `main` · +161 −4 · 3 files · 1 commits · open `extent_bank(..., limit=...)` checks the caller's extent limit for computed chunk tables, but both suffix-scan paths return their recovered extent without that check. A generated bank declaring a bank-relative extent of `0x1800` is accepted with `limit=0x1000` for flags `0xff25` and `0xff61`, and for the fallback layouts of `0xff21` and `0xff02`. Apply the same limit check to the recovered table's maximum extent. Reject the whole bank when it exceeds the limit, preserving the longest-table selection and existing alignment behavior. Also move count validation before table dispatch and before the legacy info-table read, and reject header regions outside the caller's limit or `MAX_BANK` before following them. Previously, scanned variants accepted zero or excessive stream counts, and a malformed header could cause a large read request before rejection. Seven tests use generated in-memory headers and a recording reader to cover all computed/scanned/fallback table paths, out-of-limit records before a valid final suffix, exact-limit extents at nonzero file offsets, invalid counts, oversized header reads, and valid legacy counts including `MAX_STREAMS`. The new rejection regressions fail on the original implementation. Validation with Python 3.13.5 on Windows: - `python tests/test_adat_bounds.py` — 7 tests pass. - `python tests/test_extraction_tools.py` — PASS. - `python tests/test_robustness.py --rounds 200` — PASS (231 generated inputs). - `git diff --check` — clean. This is independent of #2 and targets parser validation rather than candidate scanning. All fixtures are generated synthetic bytes; no GTA VI archives, executables, assets, dumps, or private SDK material were accessed or included. No game-runtime validation is claimed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:53:13 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3/head:github-bot/gh-3'
git switch 'github-bot/gh-3'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3'
git switch 'github-bot/gh-3'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3'
git switch 'github-bot/gh-3'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3'
git switch 'main'
git merge --squash 'github-bot/gh-3'
git switch 'main'
git merge --ff-only 'github-bot/gh-3'
git switch 'main'
git merge 'github-bot/gh-3'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.