Skip to content

Harden native string formatting and numeric input parsing - #279

Merged
ZallaxDev merged 5 commits into
ZallaxDev:integrationfrom
mkrieger95:fix/mkrieger95-bounded-forwarder-formatting
Nov 19, 2026
Merged

ZallaxDev merged 5 commits into
ZallaxDev:integrationfrom
mkrieger95:fix/mkrieger95-bounded-forwarder-formatting

Conversation

@mkrieger95

@mkrieger95 mkrieger95 commented Nov 16, 2026 •

Copy link
Copy Markdown

The HOME Menu forwarder used two unbounded sprintf calls to pack arguments into a fixed-size hb:ldr buffer. Copy the checked path as bytes and use snprintf for the restore title ID. Reject an oversized argument before sending IPC. The count, NUL-separated arguments and uppercase 16-digit title ID remain in the same format.

The optional measurement aid also checked the length of the save path before replacing its filename with a longer suffix. Check the directory prefix plus measure.txt before copying either into the buffer, and use the existing fallback path when it cannot fit.

Also reject a loader target path that would be truncated and validate the restore argument as exactly 16 hexadecimal digits before converting it. This matches the format written by the forwarder, including existing builds.

Check formatting results at three more native boundaries. Filesystem opens reject failed or truncated path formatting, settings saves refuse incomplete output before scheduling a write, and the tilemap diagnostic preserves its last complete text if an append fails.

Parse settings integers with checked strtol and validate the full speed field and its range before any float-to-int conversion. Malformed values leave the previous setting in place. Preserve valid settings text, legacy blur values, and unknown in-range numeric keys.

Validation: host checks compiled the two production snippets with UBSan and verified argument contents, the exact-fit and too-long cases, IPC call counts, and the measurement path's exact-fit and fallback cases. Additional UBSan checks covered target-path rejection, zero padding, valid 64-bit IDs, and malformed IDs. Host checks also passed for the filesystem path exact-fit, truncation and formatter-error cases, all three settings shutdown runs, and battle-speed settings. The settings tests also cover accepted half-step speeds and rejected malformed, overflowing, and non-finite inputs. git diff --check passed. The HOME Menu launch still needs a 3DS smoke test.

AI-assisted implementation.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T16:39:23.913634Z f7e5a10 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mkrieger95 mkrieger95 changed the title Bound forwarder arguments and measurement paths Harden native string formatting, launch arguments and paths Nov 16, 2026
@mkrieger95 mkrieger95 changed the title Harden native string formatting, launch arguments and paths Harden native string formatting and numeric input parsing Nov 16, 2026
@ZallaxDev

Copy link
Copy Markdown
Owner

Thanks a lot for this, @mkrieger95! We reviewed it and smoke-tested the forwarder on real hardware: the IPC layout and the hb:ldr title restore behave exactly as before, and the settings output format is unchanged.

For anyone reading later, here are the intentional behaviour changes in settings parsing:

  • trailing garbage is now ignored (speed=4junk is no longer accepted),
  • voxel, fps, run and voxel_battle only accept 0 or 1 (previously voxel=2 silently meant off),
  • out-of-range, negative, NaN and inf values are discarded,
  • \r\n line endings and trailing spaces still work.

Merging, thanks again for the careful hardening work!

@ZallaxDev
ZallaxDev merged commit 310a958 into ZallaxDev:integration Nov 19, 2026
5 checks passed
@mkrieger95
mkrieger95 deleted the fix/mkrieger95-bounded-forwarder-formatting branch November 19, 2026 20:02
DannyM90 added a commit to DannyM90/emerald-3ds that referenced this pull request Nov 19, 2026
ZallaxDev added a commit that referenced this pull request Nov 21, 2026
- public_sync: an integration commit is held when each file has what it adds; changelog credits beside the pull requests' own entries
- Changelog: public pull requests #190 #209 #262-#300, by their authors
- public_sync: dev takes integration's ported pull requests as their own commits; a conflict or unported pull requests are problems, not a line
- Public export: the benchmark, profiling and macOS builder test tools (#293, #295, #300)
- Public export: upstream.lock's Python 3.15.2 and Pillow 13.0.0 (#288, #289)
- Harden Emerald 3DS runtime and builder workflows (#300)
- Replace deprecated Pillow pixel reads in voxel tools (#294)
- Add opt-in macOS standalone builder support (#295)
- Locales: move the Japanese span in main_menu.c past the main menu card (#298)
- Fly map: choose the destination with the +Control Pad (#267)
- Bottom screen: a tap on the map that slides a little still goes on with a message (#281)
- Summary: give the trainer memo room for a third line (#269)
- Summary: show Pokémon status icons (#270)
- Main menu: the saved game's trainer card on the top screen (#284)
- Restore Japanese naming marks and full touchscreen rows (#275)
- Speed up voxel generation to shorten development builds (#293)
- Release: ship bottom/menu_top.bin with the engine files (#280)
- Bag: planting a berry opens it in the bottom screen's window (#283)
- Frontier Pass map: the picture half as big again, filling its plate (#282)
- CI: support Ubuntu 26.04 with non-PIE sanitizer fixtures (#290)
- Startup: the data pack errors and the START hint in French and Italian (#209)
- Installation: step-by-step builder for Linux and macOS (#190)
- Bottom screen: reuse unchanged wild-list snapshots (#273)
- Upgrade release builds to Pillow 13.0.0 (#289)
- Naming screen: a tab turns straight to its page (#287)
- ci: upgrade GitHub Actions to latest tested releases (#292)
- Generate map event IDs for standalone voxel host tests (#277)
- Tests: update the voxel draft chunk fixture (#262)
- Harden native string formatting and numeric input parsing (#279)
- Build releases with Python 3.15.2 (#288)
- Visible wild: roll the IVs right after the personality (PID/IV legality) (#266)
- CI: use the release toolchain for 3DS builds (#286)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants