fix(libSceAjm.native): validate Vorbis setup packet lengths #15021

Merged
MarcZX10 merged 5 commits from upstream-pr/15021 into main 2026-11-06 06:26:31 +00:00
MarcZX10 commented 2026-11-02 10:39:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T10:39:19Z.


What

sceAjmDecWVorbisCreateHeaderPacket builds the Vorbis header table from the setup packet, but it did not validate the setup packet lengths:

  • The second setup length is written as setupPacketSize - part1 truncated to 16 bits. A setup packet larger than 0xFFFF bytes produced a table that did not match the copied packet. Such packets are now refused with AJM_WVORBIS_ERROR_INVALID_SETUP before anything is written.
  • The first setup part length is read from the packet. When it was larger than setupPacketSize, the subtraction wrapped and a garbage length was written. Such packets are now refused with AJM_WVORBIS_ERROR_INVALID_SETUP.

Commits: two fix(libSceAjm.native) commits, each followed by its test(libSceAjm.native) commit.

Tested

Ubuntu host, throwaway archive build via the shared build lock:
ctest -R '^guest_ajm_wvorbis$' on the head commit: 1/1 passed.

Not run against the unfixed code (no negative control was run on this PR).
Not run on Windows, macOS or console.

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:5118936860 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15021). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T10:39:19Z. --- ### What `sceAjmDecWVorbisCreateHeaderPacket` builds the Vorbis header table from the setup packet, but it did not validate the setup packet lengths: - The second setup length is written as `setupPacketSize - part1` truncated to 16 bits. A setup packet larger than `0xFFFF` bytes produced a table that did not match the copied packet. Such packets are now refused with `AJM_WVORBIS_ERROR_INVALID_SETUP` before anything is written. - The first setup part length is read from the packet. When it was larger than `setupPacketSize`, the subtraction wrapped and a garbage length was written. Such packets are now refused with `AJM_WVORBIS_ERROR_INVALID_SETUP`. Commits: two `fix(libSceAjm.native)` commits, each followed by its `test(libSceAjm.native)` commit. ### Tested Ubuntu host, throwaway archive build via the shared build lock: `ctest -R '^guest_ajm_wvorbis$'` on the head commit: 1/1 passed. Not run against the unfixed code (no negative control was run on this PR). Not run on Windows, macOS or console. ### 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
mashingaan commented 2026-11-02 11:33:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mashingaan on 2026-11-02T11:33:29Z.

Review: APPROVED


Reviewed the current head dd18eea3b1. The two length checks prevent truncation of the 16-bit table field and subtraction underflow before output is written. The exact-head Hosted Windows build and required checks pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5735912189 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15021#pullrequestreview-5735912189). Originally posted by [mashingaan](https://github.com/mashingaan) on 2026-11-02T11:33:29Z. **Review:** APPROVED --- Reviewed the current head dd18eea3b139803ac58e737ead1ee24ebff104ac. The two length checks prevent truncation of the 16-bit table field and subtraction underflow before output is written. The exact-head Hosted Windows build and required checks pass.
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!15021
No description provided.