mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:05:53 +01:00
[PR #656] rpf9dump: harden segment bounds and CLI option validation (RPF9DUMP-SEGMENTS-AND-CLI) #695
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#695
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/656
Author: @kirigayakazima
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/rpf9dump-segments-and-cli📝 Commits (1)
c28b21arpf9dump: harden segment bounds and CLI option validation (RPF9DUMP-SEGMENTS-AND-CLI)📊 Changes
4 files changed (+49 additions, -5 deletions)
View changed files
📝
tests/Rpf9DumpDiagnostics/Program.cs(+9 -0)📝
tests/test_rpf9dump_exit_codes.py(+28 -0)📝
tools/rpf9dump/Program.cs(+8 -4)📝
tools/rpf9dump/Segments.cs(+4 -1)📄 Description
Claimed in the coordination issue as: RPF9DUMP-SEGMENTS-AND-CLI (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129604877)
What and why
Follow-up hardening to merged #6344 (now on
main) acrosstools/rpf9dump/:tools/rpf9dump/Segments.cs(RecoveredResource.Read):Int64overflow inblock.Offset + block.StoredSize > file.Lengthby checkingblock.Offset > file.Length || block.StoredSize > file.Length - block.Offset(matchingRecoveryIndexCache's subtraction guard). Previously, e.g.(Offset=32, StoredSize=long.MaxValue)wrapped negative, passed the bounds check, and read a valid compressed stream starting at offset 32.block.IsRaw && block.StoredSize != block.SizewithInvalidDataExceptioninstead of copying a partial or mismatched slice.tools/rpf9dump/Program.cs:argv[i] is not ("--start" or "--length")) before validating the value argument so bare--bogusor--bogus notanumberreportsUnknown option --bogus.rather than claiming itneeds a non-negative byte count., and emit both diagnostics onConsole.Error.--jobswithNumberStyles.None, CultureInfo.InvariantCulture(consistent with--start/--length) so+2/ whitespace / locale digits are rejected cleanly with exit code 2.tests/Rpf9DumpDiagnostics/Program.cs&tests/test_rpf9dump_exit_codes.py:StoredSizeand mismatched raw-blockStoredSize != Size(both>and<).--jobsvalues leaving output directories uncreated.(Keeps
tests/test_rpf9dump_exit_codes.pylines 87–120 untouched so this merges cleanly alongside #655.)Tested
On Windows 11 x64 (
.NET 8.0.401,Python 3.14.7) atc28b21aa6151a3f572d4b8ab066c96fe8fe72f94, synthetic fixtures only (no game data):dotnet build tools/rpf9dump/rpf9dump.csproj -c Release— 0 warnings, 0 errorsdotnet run --project tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj -c Release— all 6 suites passed (including new overflow and raw-block mismatch checks)python -I tests/test_rpf9dump_exit_codes.py -v ...(all 8 non-blocker tests, including both new CLI tests) — 8 passed, 0 failedpython -I tests/test_rpf9dump_exit_codes.py— 8 passed, 2 pre-existing failures frommain(test_failed_xma_write_exits_nonzero_and_rerun_completes&test_failed_texture_write_exits_nonzero_and_withholds_manifestdue tob05999eb'sUtil.PartialName; fixed separately in #655)python -I tests/test_ttpf_export_resume.py— 4 ran, OKpython -I tests/test_ci_registration.py— 15 ran, OKpython -I tests/test_text_write_line_endings.py— 3 ran, OKpython -I tests/test_check_no_game_data.py&python -I scripts/check_no_game_data.py— OK / exit 0python -m compileall -q make_game.py tools tests— exit 0GPUs tested: n/a
AI-assisted: yes
Checklist
main(21625bca) and merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a —rpf9dumponly)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.