fix(libSceSaveData.native): validate directory name in sceSaveDataBackup #12644

Merged
slopgobblercobbler merged 1 commit from upstream-pr/12644 into main 2026-10-30 01:52:13 +00:00
slopgobblercobbler commented 2026-10-28 23:52:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-10-28T23:52:37Z.


What

  • Validates directory names in sceSaveDataBackup (core/libs/prx/libSceSaveData.native/Export.cpp), returning SAVE_DATA_ERROR_PARAMETER (0x809f0001) for unterminated names, empty names, ., .., or names containing path delimiters (/, \, :), matching the behavior of sceSaveDataMount3, sceSaveDataDelete, and sceSaveDataConvert.
  • Removes undocumented inline comments from sceSaveDataBackup in Export.cpp per docs/dev/CONVENTIONS.md.
  • Documents sceSaveDataBackup directory name parameter validation in docs/dev/debt/libSceSaveData.native.md keeping the entry under the 1,000-character limit.
  • Expands unit test coverage in core/libs/tests/GuestSaveDataMountStatus.cpp to verify rejection of invalid directory names ("", ".", "..", "a/b", "a\b", "c:d"), unterminated names, and successful queuing and retrieval of valid backup events through sceSaveDataGetEventResult.

Tested

  • Windows 11 (x86_64), standalone compilation with clang++ (LLVM 21.1.0) under C++20, executed guest_savedata_mount_status_tests passing all assertions (0 failures).
  • Ran python tools/check_conventions.py --base upstream/main --head HEAD (all conventions checks passed with 0 findings).

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:5059580278 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12644). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-10-28T23:52:37Z. --- ### What - Validates directory names in `sceSaveDataBackup` (`core/libs/prx/libSceSaveData.native/Export.cpp`), returning `SAVE_DATA_ERROR_PARAMETER` (`0x809f0001`) for unterminated names, empty names, `.`, `..`, or names containing path delimiters (`/`, `\`, `:`), matching the behavior of `sceSaveDataMount3`, `sceSaveDataDelete`, and `sceSaveDataConvert`. - Removes undocumented inline comments from `sceSaveDataBackup` in `Export.cpp` per `docs/dev/CONVENTIONS.md`. - Documents `sceSaveDataBackup` directory name parameter validation in `docs/dev/debt/libSceSaveData.native.md` keeping the entry under the 1,000-character limit. - Expands unit test coverage in `core/libs/tests/GuestSaveDataMountStatus.cpp` to verify rejection of invalid directory names (`""`, `"."`, `".."`, `"a/b"`, `"a\b"`, `"c:d"`), unterminated names, and successful queuing and retrieval of valid backup events through `sceSaveDataGetEventResult`. ### Tested - Windows 11 (x86_64), standalone compilation with clang++ (LLVM 21.1.0) under C++20, executed `guest_savedata_mount_status_tests` passing all assertions (0 failures). - Ran `python tools/check_conventions.py --base upstream/main --head HEAD` (all conventions checks passed with 0 findings). ### 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
adriadam10 commented 2026-10-29 00:26:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-29T00:26:45Z.

Review: CHANGES_REQUESTED


Thanks for the PR. One blocking point:

  • core/libs/prx/libSceSaveData.native/Export.cpp:288-295: the PR says this matches sceSaveDataMount3/Delete/Convert, but for Backup neither reference validates the name: KytyPS5 libSaveData.cpp:1261 and shadPS4 savedata.cpp:539 only check null pointers and queue the event. The SDK 12.000 page cited in the debt entry documents sceSaveDataMount3, not Backup (there is no backup page in that repo). Returning SAVE_DATA_ERROR_PARAMETER where both references return OK is a behaviour change with no source.
  • docs/dev/debt/libSceSaveData.native.md:26: the entry says the Backup behaviour matches the SDK reference and KytyPS5; for Backup it does not, so it must not claim that.

What would fix it: cite a source that shows Backup rejects these names, or keep only the part that is needed regardless of any source (the unterminated name, which would otherwise copy dir_name without a terminator check), and say in the debt entry that the rest is unverified. Please keep the test changes that match whatever stays.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5691411590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12644#pullrequestreview-5691411590). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-29T00:26:45Z. **Review:** CHANGES_REQUESTED --- Thanks for the PR. One blocking point: - `core/libs/prx/libSceSaveData.native/Export.cpp:288-295`: the PR says this matches `sceSaveDataMount3`/`Delete`/`Convert`, but for Backup neither reference validates the name: KytyPS5 `libSaveData.cpp:1261` and shadPS4 `savedata.cpp:539` only check null pointers and queue the event. The SDK 12.000 page cited in the debt entry documents `sceSaveDataMount3`, not Backup (there is no backup page in that repo). Returning `SAVE_DATA_ERROR_PARAMETER` where both references return OK is a behaviour change with no source. - `docs/dev/debt/libSceSaveData.native.md:26`: the entry says the Backup behaviour matches the SDK reference and KytyPS5; for Backup it does not, so it must not claim that. What would fix it: cite a source that shows Backup rejects these names, or keep only the part that is needed regardless of any source (the unterminated name, which would otherwise copy `dir_name` without a terminator check), and say in the debt entry that the rest is unverified. Please keep the test changes that match whatever stays.
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!12644
No description provided.