fix(ajm): reject ATRAC9 gradients beyond decoder bounds #2395

Merged
ArchitDewan merged 1 commit from upstream-pr/2395 into main 2026-10-11 08:29:27 +00:00
ArchitDewan commented 2026-10-09 18:00:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ArchitDewan on 2026-10-09T18:00:37Z.


What

Fixes #2345. LibAtrac9 now rejects gradient end units above 31 before they can write past Block::Gradient. The CMake build applies this change to a generated copy of unpack.c, leaving the pinned submodule untouched. Added a regression test for end units 31, 32 and 47.

Tested

Focused decoder regression test and sanitizer check passed locally. Full Windows and Linux builds and tests are pending CI.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4804070354 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2395). Originally posted by [ArchitDewan](https://github.com/ArchitDewan) on 2026-10-09T18:00:37Z. --- ### What Fixes #2345. LibAtrac9 now rejects gradient end units above 31 before they can write past `Block::Gradient`. The CMake build applies this change to a generated copy of `unpack.c`, leaving the pinned submodule untouched. Added a regression test for end units 31, 32 and 47. ### Tested Focused decoder regression test and sanitizer check passed locally. Full Windows and Linux builds and tests are pending CI. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
github-actions[bot] commented 2026-10-09 18:00:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T18:00:48Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086446419 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2395#issuecomment-6086446419). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T18:00:48Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
adriadam10 commented 2026-10-11 08:29:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:29:24Z.


Checked on the PR merged onto current main: the patched unpack.c is generated at configure time (fails loudly if the guard text changes), libSceAjm.native and atrac9_gradient_tests build, and atrac9_gradient passes. The same test against the unpatched unpack.c fails, and passes under ASan/UBSan with the patch. Limit 31 matches Gradient[31]. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107139541 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2395#issuecomment-6107139541). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T08:29:24Z. --- Checked on the PR merged onto current `main`: the patched `unpack.c` is generated at configure time (fails loudly if the guard text changes), `libSceAjm.native` and `atrac9_gradient_tests` build, and `atrac9_gradient` passes. The same test against the unpatched `unpack.c` fails, and passes under ASan/UBSan with the patch. Limit 31 matches `Gradient[31]`. Merging.
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!2395
No description provided.