mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1575] psocache_extract: stop at --max-streams, guard output path/overwrites, fix MAX_GAP & inside_tempdir, and write atomically (PSOCACHE-EXTRACT-GUARDS-AND-IO) #1596
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#1596
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/1575
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/psocache-extract-guards-and-io📝 Commits (1)
cb395b7psocache_extract: stop at --max-streams, guard output path/overwrites, fix MAX_GAP & inside_tempdir, and write atomically📊 Changes
2 files changed (+184 additions, -13 deletions)
View changed files
📝
tests/test_psocache_extract.py(+108 -0)📝
tools/psocache_extract.py(+76 -13)📄 Description
Item ID:
PSOCACHE-EXTRACT-GUARDS-AND-IO(new item; coordination issue #14 is at GitHub's 2,500-comment cap with no open successor at PR time — confirmed 0 open PRs touchtools/psocache_extract.py)Summary
--max-streamsis reached:extract()previously checked onlyleft <= 0, continuing to open, mmap, and report0 streamsfor every later archive in a folder even after hitting--max-streams.outbefore scanning and guard source archives: reject empty/whitespace paths, existing directories, missing parent directories, and anyoutpath aliasingsourceor an archive insource(usingreport_paths.same_report_path) soextract()can never overwrite a source archive inside the temp directory or scan gigabytes before failing on a bad output path.inside_tempdir()edge cases: reject empty/whitespace paths (previouslyinside_tempdir("")returnedTruewhencwdwas inside the temp dir), useos.path.commonpathwith case-folding on Windows/APFS soTMPDIR=/and case-variant paths work properly.MAX_GAPpadding check inassemble(): allow up toMAX_GAP(1 MiB) zero bytes between contiguous streams as documented, rejectingMAX_GAP + 1.OSErrorinarchives()without leaking the package path, close the archive mmap before writing, and publish the output atomically viaNamedTemporaryFile+file_mode.published_mode+replace_retry.replace. Also guardheader is Noneand non-positivebudget/max_streamsinextract().Testing
python3 -W error -I tests/test_psocache_extract.py -v: 12/12 passedpython3 -W error -I tests/test_text_write_line_endings.py -v: 3/3 passedpython3 -I scripts/check_no_game_data.py tools/psocache_extract.py tests/test_psocache_extract.py: passedpython3 -m compileall -q make_game.py tools tests: passedmain:tools/psocache_extract.py: all 5 new tests fail (FAILED (failures=3, errors=2)).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.