psocache_inspect: guard --entry bounds, zero-meta references, and header string slots (PSOCACHE-INSPECT-BOUNDS-AND-REFS) #1454
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1454"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T00:31:45Z.
Claimed in the coordination issue as: PSOCACHE-INSPECT-BOUNDS-AND-REFS
Summary
Hardens
tools/psocache_inspect.pyagainst malformed/corrupt PSO cache inputs and zero-entry meta-index edge cases:--entrybounds & truncated-meta handling (inspect(),parse_chunks()):inspect(..., entry=N)passedentries[N]straight todescribe_entry()without checkinga + b <= meta_size, raising an uncaughtstruct.errorwhen an index entry pointed past EOF or silently decoding bytes fromcode_blobwhen it spilled pastmeta_blob. Now reports"entry offset 0x... size ...: points past the 0x...-byte meta blob"cleanly.meta_indexormeta_blobdoes not fit in a truncated file,--entryis now rejected withValueErrorinstead of being silently ignored (meta_entry: None).entryand booleanentry/limitarguments upfront, and bounds-checks(base, start, size)insideparse_chunks().meta_index == 0:if ... and counts["meta_index"]:skipped reference validation completely whenmeta_index == 0, letting non-hole graphics/compute references pass with"verdict": "model holds"(exit 0). Now runs whenevergraphics,compute, ormeta_indexis non-zero.0x04..0x24,0x24..0x48):m.find(b"\x00", off, HEADER_SIZE)scanned past each string's fixed slot into string 1 /HASH_OFF(0x48) / counts when unterminated. Now bounds each scan to its slot (STRING_BOUNDS = ((0x04, 0x24), (0x24, HASH_OFF))) and records a problem if unterminated.Testing
arm64), Python 3.14 (CPU-only, synthetic cache fixtures only, no game data)python3 -m compileall -q make_game.py tools tests-> cleanpython3 -I scripts/check_no_game_data.py tools/psocache_inspect.py tests/test_psocache_inspect.py-> cleanpython3 -I tests/test_psocache_inspect.py -v-> 19/19 OK (5 new tests)python3 -I tests/test_text_write_line_endings.py-> 3/3 OKpython3 -I tests/test_ci_registration.py-> 16/16 OKtests/test_psocache_inspect.pyon unpatchedupstream/mainb4b7756e8):FAILED (failures=4, errors=2)(reproducingstruct.erroron OOB--entryandparse_chunks, silent--entryignore on truncated meta, skippedreferencesonmeta_index == 0, and header string bleed lengths34/36).Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T00:32:00Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T10:15:17Z.
Red/green: the PR's tests fail on main
4938673and pass on head4f56b089d9(Linux, Python 3.13.18).Targeted batch of 11 PRs (their tests, the tests importing the changed modules, the docs tests) on main
3ca0707: no new failure, Linux / Python 3.13.AI-assisted (Claude Code, Claude Opus 5.5)