fix(check): a damaged .nup header is refused in 176 bytes, and the check's memory is bounded #252
No reviewers
Labels
No labels
area/build
area/install
area/saves
area/tooling
area/ui
area/updates
ci: approved
good first issue
gpu/amd
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
platform/linux
platform/steam-deck
platform/windows
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/LongshotLauncher!252
Loading…
Reference in a new issue
No description provided.
Delete branch "dazemc/LongshotLauncher:fix/nup-toc-memory"
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?
The Linux launcher sat on "Checking…" for a
.nupand took the PC's memory: Longshot#1525 saw 59.1 GiB of 60.4 GiB inuse. The check starts Longshot's tools, and
nx2/nup.py(Nup.__init__,:143-159) trusts a damaged table of contentsbefore checking it —
meta = f.read(0x80 + strings offset + strings size)reads up to the whole file, thenself.strings = meta[...]copies the names again. The launcher had no bound of its own either: it kept every line thecheck wrote, and put no limit on the check's process tree. This is the launcher's half of #1525;
nx2/nup.pyitself is@dyst's and is not touched here.
What changed
Core/NupIndex.cs: a.nup's header and the header of its table of contents are read first — 0xB0 = 176 bytes,whatever the file says it is — and a table that cannot fit the file, or is far larger than a game dump's (256 MiB TOC,
64 MiB names, 2.5 M files), is refused before any tool starts, with the plain "damaged" or "incomplete" words. The
wizard's game-file check asks this before it runs
make_game.py --check.MakeGameRun.Bounded: on Linux the check runs under an inheritedRLIMIT_AS— half the PC's memory, 1 to 2 GiB —set with bash's
ulimit -vbefore the toolsexec, somake_game.pyand thenx2/nup.pyit starts inherit it and no.nupshape (a zstd frame's window included) can take more from the PC.CheckAsynckeeps the check's last 512 lines instead of every line.the file was blamed instead of this PC.
tests/launcher_core's "Tools that do not start: this PC's, not the file's"caught it; the wrap's own check now puts its program on the disk and a new check holds a missing program unwrapped.
Evidence (this PC, no game launch, no game data)
The launcher's own preflight on the real 25,622,267,860-byte stable dump and on three damaged headers, through a counting
stream:
The old path, on the same files:
of payload, which is what the 1–2 GiB limit and the 256 MiB TOC cap are sized from;
before the records are built,
MemoryErroratnx2/nup.py:143underulimit -v 2 GiB(the limit this branch nowsets), and OOM-killed under a
MemoryMax=2Gscope. On the reporter's PC, with a header whose offsets land near theend of the file, the measured 2.3× is the 59.1 GiB they saw.
The sparse file is a header and a hole: no game data is in it, and nothing leaves this PC.
Tests
tests/launcher_core(built fromCore/atb372d00, run the waytests/test_launcher_core.pyruns it):2704 checks passed, 0 warnings, 0 errors — including the new
NupIndexChecks: a sound dump accepted from 176 bytes,a 1 TiB header with names past its TOC refused from 176 bytes, every count and offset bound refused, and the wizard
reading
NupIndex.Whybefore it starts the tools.tests/test_release.py: 42 tests, OK.python -I tests/test_launcher_core.pystill stops at its translation gate: 48 "left over" catalog texts, and thesame 48 with the same texts on
main(6887d57) — the state @dyst's open #246 fixes. This branch changes no catalogtext and no launcher string the catalogs hold; it is red on
mainand here alike.Ready for review
fix/nup-toc-memory), Conventional Commits.NupIndexreads a stream, Windows and Linux alike; the limit is Linux's, where the report is.nx2/nup.pyleft to its owner (#1525).Possibly related, for context:
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.