mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:15:51 +01:00
[PR #1611] psocache_usersig: guard second open/mmap, validate --entry/limit/bounds, and reject empty path (PSOCACHE-USERSIG-GUARDS) #1626
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#1626
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/1611
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/psocache-usersig-guards📝 Commits (1)
d8f2ac6psocache_usersig: guard second open/mmap, validate --entry/limit/bounds, and reject empty path📊 Changes
2 files changed (+137 additions, -41 deletions)
View changed files
📝
tests/test_psocache_usersig.py(+80 -0)📝
tools/psocache_usersig.py(+57 -41)📄 Description
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).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.