fix(libSceJson2): reject a null allocParam in the legacy RTTI constructor #16344

Merged
MarcZX10 merged 2 commits from upstream-pr/16344 into main 2026-11-10 09:52:01 +00:00
MarcZX10 commented 2026-11-06 10:17:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-06T10:17:13Z.


What

The legacy sce::Json::InitParameterRtti constructor (_ZN3sce4Json17InitParameterRttiC1EPNS0_14AllocParamRttiEPvm) dereferenced allocParam without a null check when no module was active, so a guest passing nullptr crashed the host process. The sibling setAllocatorRtti already returns early on a null argument; the constructor now does the same after clearing the 24-byte parameter block, which it already did before any other check.

  • fix(libSceJson2): reject a null allocParam in the legacy RTTI constructor: one early return in Export.cpp.
  • test(libSceJson2): cover a null allocParam in the legacy RTTI constructor: with no active module, the constructor called with nullptr must clear exactly its 24-byte base and leave the trailing bytes of the object untouched.

Tested

Linux, throwaway archive build of this head: BUILD-EXIT 0, ctest guest_json_allocator_settings (target guest_json_allocator_settings_tests) passed, 1 of 1. python3 tools/check_conventions.py --base upstream/main and git diff --check are clean. The new case was not run against the unfixed code; that it fails without the fix is reasoned from the code (a null read). Not run on Windows or macOS.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5186318370 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16344). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-06T10:17:13Z. --- ### What The legacy `sce::Json::InitParameterRtti` constructor (`_ZN3sce4Json17InitParameterRttiC1EPNS0_14AllocParamRttiEPvm`) dereferenced `allocParam` without a null check when no module was active, so a guest passing `nullptr` crashed the host process. The sibling `setAllocatorRtti` already returns early on a null argument; the constructor now does the same after clearing the 24-byte parameter block, which it already did before any other check. - `fix(libSceJson2): reject a null allocParam in the legacy RTTI constructor`: one early return in `Export.cpp`. - `test(libSceJson2): cover a null allocParam in the legacy RTTI constructor`: with no active module, the constructor called with `nullptr` must clear exactly its 24-byte base and leave the trailing bytes of the object untouched. ### Tested Linux, throwaway archive build of this head: `BUILD-EXIT 0`, ctest `guest_json_allocator_settings` (target `guest_json_allocator_settings_tests`) passed, 1 of 1. `python3 tools/check_conventions.py --base upstream/main` and `git diff --check` are clean. The new case was not run against the unfixed code; that it fails without the fix is reasoned from the code (a null read). Not run on Windows or macOS. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
gabichuuuuu commented 2026-11-08 23:28:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T23:28:23Z.

Review: COMMENTED


Windows run of head d4dcfae8fd, merged onto main 286b14d2f7 in one tree with 41 other small open PRs that touch different files. Setup: Windows 11, WinLibs GCC 15.2 r7 (x86_64-ucrt-posix-seh, the CI toolchain), Release, BUILD_TESTING=ON.

  • guest_json_allocator_settings with --repeat until-fail:5: 5 / 5 pass.
  • Negative control, with main's Export.cpp and this PR's test: 5 / 5 runs fail.

With a null allocParam, the constructor leaves *self zeroed and installs nothing.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5820177379 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16344#pullrequestreview-5820177379). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-08T23:28:23Z. **Review:** COMMENTED --- Windows run of head `d4dcfae8fd`, merged onto `main` `286b14d2f7` in one tree with 41 other small open PRs that touch different files. Setup: Windows 11, WinLibs GCC 15.2 r7 (`x86_64-ucrt-posix-seh`, the CI toolchain), Release, `BUILD_TESTING=ON`. - `guest_json_allocator_settings` with `--repeat until-fail:5`: 5 / 5 pass. - **Negative control,** with `main`'s `Export.cpp` and this PR's test: 5 / 5 runs fail. With a null `allocParam`, the constructor leaves `*self` zeroed and installs nothing.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!16344
No description provided.