psocache_usersig: guard second open/mmap, validate --entry/limit/bounds, and reject empty path (PSOCACHE-USERSIG-GUARDS) #1611
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1611"
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-25T05:54:42Z.
Item ID:
PSOCACHE-USERSIG-GUARDS(unlisted; coordination issue #14 is at GitHub's 2,500-comment cap with no open successor at submission time, and no open PR touchestools/psocache_usersig.py).What changed
open()/mmap.mmap()/ decode pass inmain()(tools/psocache_usersig.py): previously onlypsocache_inspect.inspect()was insidetry/except, so a cache file disappearing, becoming unreadable, or shrinking betweeninspect()and the second open crashed with an unhandled traceback instead of returning exit code2. Also checklen(m) < report["size"]in shared helper_load_meta().--entrybounds before re-opening or parsingmeta_index: out-of-range--entry(negative or>= counts["graphics"]) now exits2immediately afterinspect()instead of re-opening, mmapping, and parsing every meta chunk record first.cacheCLI arguments upfront with exit2usage error and enforceallow_nan=Falseon--jsonoutput.summarise,describe_pso,stage_record_refs):summarise()rejects non-int/bool/< 1limit(previouslylimit=-3returned"sampled": -3andlimit=Truesilently sampled 1).describe_pso()rejects negative /bool/ out-of-boundsindexwithValueErrorinstead of negative offset wraparound or rawstruct.error.stage_record_refs()rejectsboolstageand checksa >= 0andmeta_off + a + p + 4 <= len(m)before unpacking.tests/test_psocache_usersig.py): 4 new tests covering all of the above (no game files, no GPU).Verification
python3 -W error -I tests/test_psocache_usersig.py -v: 12 passedpython3 -W error -I tests/test_text_write_line_endings.py: passedpython3 -I scripts/check_no_game_data.py tools/psocache_usersig.py tests/test_psocache_usersig.py: cleanpython3 -m compileall -q tools/psocache_usersig.py tests/test_psocache_usersig.py: cleantests/test_psocache_usersig.pyagainst unpatchedmain:tools/psocache_usersig.py): 8 failures, 3 errors across the 12 tests (all 4 new tests fail on unpatchedmain).Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T05:54:49Z.
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:38:32Z.
Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 18 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)