OLD-7928: analyze_4240_full: guard trailing high-bit words, bound zlib inflation, validate limit, and write JSON atomically #890

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

@⁠narekshaghoyandev on GitHub · 2026-11-24 14:58 UTC · original
narekshaghoyandev:ubiq-analyze-4240-full-bounds-and-zlib-cap → main · +130 −26 · 2 files · 1 commits · open

Reopening my original upstream PR #7928 cleanly rebased onto main:

  1. Trailing high-bit word crash & false group counting (process_archive): Guards pos + 12 <= len(stream_data) before reading triangles/refs so negative float vertex data in the final 4..11 bytes of a stream cannot crash the archive scan with ValueError, and only counts stats["groups"] when the group fits in the stream.
  2. Bounded zlib inflation (_inflate_bounded, iter_archive_streams): Replaces unbounded d.decompress(block) with chunked decompression capped at max_inflate (64 MiB default) to prevent OOM on zlib bombs.
  3. API --limit validation (process_archive): Rejects limit < 1 and bool directly in process_archive.
  4. Atomic JSON report writes (write_json, main): Publishes --json via tempfile.mkstemp + file_mode.published_mode + replace_retry.replace with allow_nan=False, trailing LF, and read-only-safe temp cleanup.

Verification

  • python3 -I tests/test_analyze_4240_full.py -v: 19/19 pass (all 3 new tests fail/error against main).
  • python3 -I scripts/check_no_game_data.py tools/analyze_4240_full.py tests/test_analyze_4240_full.py: clean.
  • python3 -m compileall -q tools/analyze_4240_full.py tests/test_analyze_4240_full.py: clean.

Claimed in the coordination issue as: OLD-7928 (#14)
AI-assisted: yes (Gemini)

**@⁠narekshaghoyandev** on GitHub · 2026-11-24 14:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/890) `narekshaghoyandev:ubiq-analyze-4240-full-bounds-and-zlib-cap` → `main` · +130 −26 · 2 files · 1 commits · open Reopening my original upstream PR #7928 cleanly rebased onto `main`: 1. **Trailing high-bit word crash & false group counting (`process_archive`)**: Guards `pos + 12 <= len(stream_data)` before reading `triangles`/`refs` so negative float vertex data in the final 4..11 bytes of a stream cannot crash the archive scan with `ValueError`, and only counts `stats["groups"]` when the group fits in the stream. 2. **Bounded zlib inflation (`_inflate_bounded`, `iter_archive_streams`)**: Replaces unbounded `d.decompress(block)` with chunked decompression capped at `max_inflate` (`64 MiB` default) to prevent OOM on zlib bombs. 3. **API `--limit` validation (`process_archive`)**: Rejects `limit < 1` and `bool` directly in `process_archive`. 4. **Atomic JSON report writes (`write_json`, `main`)**: Publishes `--json` via `tempfile.mkstemp` + `file_mode.published_mode` + `replace_retry.replace` with `allow_nan=False`, trailing LF, and read-only-safe temp cleanup. ### Verification - `python3 -I tests/test_analyze_4240_full.py -v`: 19/19 pass (all 3 new tests fail/error against `main`). - `python3 -I scripts/check_no_game_data.py tools/analyze_4240_full.py tests/test_analyze_4240_full.py`: clean. - `python3 -m compileall -q tools/analyze_4240_full.py tests/test_analyze_4240_full.py`: clean. Claimed in the coordination issue as: OLD-7928 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) AI-assisted: yes (Gemini)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:26:30 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 21:05 UTC · original

Reviewed fdcdb6043: hardening of analyze_4240_full (trailing high-bit word guard, 64 MiB inflate bound, limit validation, atomic staged --json write). I ran its test file on the PR tree (19 OK) and copied onto main (all 3 new tests fail there, 16 old pass), the exit-code, line-endings, compileall and no-game-data checks (clean), and a synthetic probe on both trees: stream discovery identical, _inflate_bounded byte-exact, the walker ValueError crash reproduces only on main. Note: the branch is behind main (test_tool_stdout_encoding.py fails on the branch naming native_pso_hashes.py, fixed later on main) - a rebase clears it. No findings. AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 21:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/890#issuecomment-7174604364) Reviewed fdcdb6043: hardening of `analyze_4240_full` (trailing high-bit word guard, 64 MiB inflate bound, `limit` validation, atomic staged `--json` write). I ran its test file on the PR tree (19 OK) and copied onto main (all 3 new tests fail there, 16 old pass), the exit-code, line-endings, compileall and no-game-data checks (clean), and a synthetic probe on both trees: stream discovery identical, `_inflate_bounded` byte-exact, the walker ValueError crash reproduces only on main. Note: the branch is behind main (`test_tool_stdout_encoding.py` fails on the branch naming `native_pso_hashes.py`, fixed later on main) - a rebase clears it. No findings. AI-assisted review. **Recommendation:** Merge
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/890/head:github-bot/gh-890'
git switch 'github-bot/gh-890'

Merge

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