Repository navigation
packing/nup: read meta blocks that nup numbers one too low, and leave out a NACP that is not 0x4000 bytes - #2879
Closed
oliverames wants to merge 1 commit into
Closed
oliverames wants to merge 1 commit into
oliverames wants to merge 1 commit into
Conversation
3 tasks done
Upstream nup PR seedds#20 started its TLV enum at 0 instead of SPEC §5's 1. This wrote JPEG icons at the NACP type and display versions at the icon type. Normalize affected blocks at the shared reader. Prefer NACP and icon content, then use the markers described in upstream nup PR seedds#32. Preserve correctly numbered control data when it appears with shift markers. Reject NACP payloads of any size other than 0x4000 in the same reader. Package scanning previously trusted the ID fields of some truncated or oversized payloads, which could reject valid DLC. Filter those payloads before either scanning or extraction uses them. Verified with the upstream writer and a one-line enum correction, real shifted and SPEC-numbered archives, and synthetic regression cases for wrongly sized NACPs and valid titles beginning with META. Ported from kencalx/NX18 (3acdfeacb, 0d343ee5d, 9fffe70e0). PR seedds#2879 Co-authored-by: Oliver Ames <7366664+oliverames@users.noreply.github.com> Co-authored-by: kenCalx <105067885+kencalx@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
seedds
force-pushed
the
nx18-nup-control-data
branch
from
November 20, 2026 17:31
bdbacad to
2a61623
Compare
seedds
marked this pull request as ready for review
November 20, 2026 17:31
seedds
added a commit
that referenced
this pull request
Nov 21, 2026
Upstream nup PR #20 started its TLV enum at 0 instead of SPEC §5's 1. This wrote JPEG icons at the NACP type and display versions at the icon type. Normalize affected blocks at the shared reader. Prefer NACP and icon content, then use the markers described in upstream nup PR #32. Preserve correctly numbered control data when it appears with shift markers. Reject NACP payloads of any size other than 0x4000 in the same reader. Package scanning previously trusted the ID fields of some truncated or oversized payloads, which could reject valid DLC. Filter those payloads before either scanning or extraction uses them. Verified with the upstream writer and a one-line enum correction, real shifted and SPEC-numbered archives, and synthetic regression cases for wrongly sized NACPs and valid titles beginning with META. Ported from kencalx/NX18 (3acdfeacb, 0d343ee5d, 9fffe70e0). PR #2879 Co-authored-by: Oliver Ames <7366664+oliverames@users.noreply.github.com> Co-authored-by: kenCalx <105067885+kencalx@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thanks, Oliver and kenCalx, for tracing the NUP metadata bug and bringing the fix over. It’s on main in a1a81f7. The reader handles the shifted metadata and discards wrong-size control records before scanning or extraction can use them. All 62 NUP tests passed on GitHub. The failing checks reproduced on the original base, and the affected checks passed locally after rebasing onto main’s separate fixes. The writer correction is still pending upstream, so existing archives continue to be handled by the reader. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Oliver · project thread
What and why
Credit: this is kencalx's work from the NX18 fork, ported onto current main. kencalx is a co-author on the commit, and every measurement below that is not marked as mine is theirs.
Symptom: a NUP made by the nup tool since its PR #20 (merged 2026-11-04) writes every meta record's type one too low (NPDM 0, NACP 1, icon 2, localized icons 9). pack_nup.py read SPEC section 5's numbers, so for such a file it saved the icon JPEG as control.nacp and the display version as icon.jpg: a blank game name, a random language list and no icon. Separately, a NACP record that is not 0x4000 bytes was saved as control.nacp as it was.
Fix: Package.meta() now tells a shifted block and reads every type one up. The records decide first (the 0x4000-byte NACP at type 1 or 2, else a JPEG or PNG icon at 2 or 3); only when they cannot tell does nup's PR #32 rule decide (a record of type 0, or one of type 7 that is not 32 bytes, the build ID's size). A block from an older nup is read as it is. control() says in one line per package that it read a block one type up, and leaves out a NACP record of another size with a line; a base game's good NACP still fills in for an update that lacks one. The lines also show in a build with a profile, which otherwise packs quietly (pack_version takes a note= callback, and the NSP script's survey passes its own output to control()). docs/development.md and the README say it.
Tests: synthetic shifted and SPEC-numbered blocks, a type 7 record of 32 bytes and one of another size, shifted localized icons, wrong-size NACPs, a standalone update whose own bad NACP falls back to the base record, the line said once per package, and the build and the survey saying it. test_nsp_nup.py passes (53 tests, 12 new) with backports.zstd, lz4 and capstone installed; test_docs passes. On a Mac (M2 Pro, macOS 27.3) test_nsp_nup.py passes too (53 tests). test_nsp_mac_app.py has 23 errors both with and without this change on Linux (it needs macOS). Not checked: the Mac app build, and a real NUP written by nup (the claim about nup's PR #20 and #32 is NX18's, not re-checked).
Ported from NX18 (kencalx/NX18), by hand since the code moved: 3acdfeacb kencalx/NX18@3acdfeacb, with the follow-up fixes in 0d343ee5d and 9fffe70e0 folded in. Left out: everything about NX archive input (scripts/pack_nx.py and its tests, the title.txt and icon.edited.jpg files, the app name from an NX's display title).
Checked
scripts/regress.py check --games: not run.Docs
docs/reference/<subsystem>.mdentry: not applicable, a small internal fix with no symptom a player sees🤖 Generated with Claude Code
https://claude.ai/code/session_01RcRaRTbNVNsBJcfGqFidW1