mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:50:51 +01:00
[PR #1454] psocache_inspect: guard --entry bounds, zero-meta references, and header string slots (PSOCACHE-INSPECT-BOUNDS-AND-REFS) #1483
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1483
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1454
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/psocache-inspect-bounds-and-refs📝 Commits (1)
4f56b08psocache_inspect: guard --entry bounds, zero-meta references, and header string slots📊 Changes
2 files changed (+139 additions, -8 deletions)
View changed files
📝
tests/test_psocache_inspect.py(+109 -0)📝
tools/psocache_inspect.py(+30 -8)📄 Description
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).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.