Bound bulk extraction by indexed decoded lengths #4

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

@⁠yefan911 on GitHub · 2026-11-27 05:18 UTC · original
yefan911:fix/bulk-extract-bounds → main · +110 −2 · 3 files · 1 commits · open

Summary

bulk_extract.extract_one receives the index's expected decoded length, but currently ignores it and calls unbounded zlib.decompress. Incorrect lengths are silently accepted and written; a small indexed size also does not constrain the allocation of a highly compressed stream.

For a known positive size, use the incremental decoder with an output limit of expected + 1. Require both the exact decoded length and a complete stream before creating any output directory or file. Keep zero/unknown-length entries on the existing path. Update the module description to make that qualification explicit.

Validation

  • Five new synthetic regression tests cover exact content/digests, unknown sizes, smaller/larger indexed sizes, truncated streams, and an 8 MiB expansion with a 16-byte indexed size.
  • Against the committed implementation, the size-mismatch and large-expansion cases produce three expected failures; the existing-behavior controls pass.
  • With the fix, all five tests pass on both native Windows and Ubuntu WSL. The large-expansion case stays below 512 KiB of Python-traced allocations and writes no output.
  • Existing tests/test_extraction_tools.py and tests/test_robustness.py --rounds 200 pass on native Windows.
  • git diff --check passes.

Tests use generated compressed bytes and temporary directories only. No game archives, assets, extracted samples, private SDK materials, or game-derived fixtures were accessed. The append-only journal records the synthetic reproduction and commands.

**@⁠yefan911** on GitHub · 2026-11-27 05:18 UTC · [original](https://github.com/lynxnathan/rage-tools-vi/pull/4) `yefan911:fix/bulk-extract-bounds` → `main` · +110 −2 · 3 files · 1 commits · open ## Summary `bulk_extract.extract_one` receives the index's expected decoded length, but currently ignores it and calls unbounded `zlib.decompress`. Incorrect lengths are silently accepted and written; a small indexed size also does not constrain the allocation of a highly compressed stream. For a known positive size, use the incremental decoder with an output limit of `expected + 1`. Require both the exact decoded length and a complete stream before creating any output directory or file. Keep zero/unknown-length entries on the existing path. Update the module description to make that qualification explicit. ## Validation - Five new synthetic regression tests cover exact content/digests, unknown sizes, smaller/larger indexed sizes, truncated streams, and an 8 MiB expansion with a 16-byte indexed size. - Against the committed implementation, the size-mismatch and large-expansion cases produce three expected failures; the existing-behavior controls pass. - With the fix, all five tests pass on both native Windows and Ubuntu WSL. The large-expansion case stays below 512 KiB of Python-traced allocations and writes no output. - Existing `tests/test_extraction_tools.py` and `tests/test_robustness.py --rounds 200` pass on native Windows. - `git diff --check` passes. Tests use generated compressed bytes and temporary directories only. No game archives, assets, extracted samples, private SDK materials, or game-derived fixtures were accessed. The append-only journal records the synthetic reproduction and commands.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 05:22:12 +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/4/head:github-bot/gh-4'
git switch 'github-bot/gh-4'

Merge

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