Repository navigation
saves: reject JSAV blocks outside the JSON body - #2603
Conversation
|
Checked I had checked the first head Refreshed appended-block case on Also probed on this head: a second JSON document no entry points at ("JSAV has non-padding data after the JSON No defect found in AI-assisted review. |
|
Independent Windows check of One boundary case remains if the guard is intended to cover the JSON body itself. I appended a copy of the first block after the original save's zero padding, then pointed entry 0 at that appended block. In the synthetic fixture, the outer JSON ends at byte 933 and entry 0 starts at 944. With that fixture, AI-assisted. Synthetic files only, with no game files or GPU. |
|
Reproduced the appended-block case and corrected it in f1d4504. Added your case plus regressions for malformed JSON, a trailing document, invalid UTF-8, non-ASCII byte offsets and whitespace before zero padding. Invalid inputs leave an existing The PR description and local checkpoint now reflect the correction. AI-assisted with Codex. |
|
Tested f1d4504 merged onto AI-assisted (Claude Code); runs on my machine. |
A malformed JSAV entry can point outside its actual JSON document. Python slicing silently returns empty or truncated bytes, so
extractcould report success anddiffcould report identical blocks for damaged saves. Parse the outer UTF-8 JSON first, convert its end position to a byte offset, validate every entry against that boundary, and reject non-padding trailing data. Errors return exit code 2 before block exports are created or overwritten.Claim: #2516 (comment) (new JSAV entry-bounds item). Independent of #1438's output-path validation and #2504's signature probing.
The regression cases include offsets into the header/table/padding, truncated and uint32-sized extents, and the appended-block boundary case raised in review. Invalid JSON, trailing documents and invalid UTF-8 preserve prior exports; non-ASCII content uses byte offsets correctly, and ordinary whitespace before zero padding remains accepted.
Validation on Windows 11 Pro, CPython 3.12.10, CPU only:
49475796; the three review regressions failed on the initial PR head24ac584b.python -I tests/test_saves.py -q: 39 passed, including parser/CLI errors, byte-identical rebuilds and extract/edit/pack round trips.python -I tests/test_saves_import_args.py: 1 passed.python -I tests/test_save_keys.py: 24 passed.python -I tests/test_text_write_line_endings.py: 2 passed on the initial patch; the review correction adds no file writers.git diff --check: passed.Synthetic containers only; no game files, GPU or driver validation. No translator or C++ runtime changes. AI-assisted with Codex.