fix(libSceAjm.native): reject ATRAC9 config data with a reserved channel configuration #5658
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5658"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-14T04:55:58Z.
What
LibAtrac9 reads the channel configuration of ATRAC9 config data as a 3-bit index (0-7) but
ChannelConfigshas six entries (3rdparty/LibAtrac9/C/src/tables.c:9), andReadConfigData(decinit.c:70) only checks the 0xFE header and the validation bit. Indices 6 and 7 therefore read past the table atdecinit.c:47and initialise a decoder from the bytes that follow; in a local buildFE 8C 0B E0was accepted with 0 channels. A bounds-checked build (-fsanitize=bounds -fsanitize-trap=bounds) traps on that line.As in #2395, the build now applies the change to a generated copy of
decinit.cinPatchLibAtrac9.cmake, leaving the pinned submodule untouched: the config data check also fails forChannelConfigIndex > 5. The patch stops configuration withFATAL_ERRORif the upstream guard changes.sceAjmDecAt9ParseConfigData, AJM initialization, libSceAudiodec and NGS2 all link the sameatrac9target and already report a failed config as invalid config data, so no PS5-facing code changes. FFmpeg rejects the same values (libavcodec/atrac9dec.c:block_config_idx > 5→ "Incorrect block config!").New test
atrac9_config_datachecks all 16 sample-rate indices × 8 channel indices: channel counts 1, 2, 2, 6, 8, 4 for indices 0-5 and rejection for 6 and 7.Tested
Windows 11 26200, WinLibs GCC 15.2.0 UCRT, full build with
BUILD_TESTING=ONonmain75690a117.decinit.ccompiled into theatrac9target:atrac9_config_datafails.atrac9_config_data,atrac9_gradientandguest_ajmpass.-fsanitize=bounds -fsanitize-trap=boundstrap atdecinit.c:47for indices 6 and 7; with the patched copy they return an error and the test exits 0.python tools/check_conventions.py --base origin/mainpasses.Not tested: Linux and macOS builds; titles (no title is known to ship such config data — this is a bounds fix for invalid input, like #2395).
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T11:37:32Z.
Rebased onto current
main(thePatchLibAtrac9.cmake/CMakeLists.txtconflict with thebit_reader.cfast-path patch) and pushed one fix:atrac9_config_data_testsdid not link on Linux (undefined reference to sin/pow/sincos, libm missing); addedmfor non-Windows.Checked: the PR's test fails with the pristine
decinit.cand passes with the patch;atrac9_config_data,atrac9_gradientandguest_ajmpass on Linux.block_config_idx > 5matches FFmpeg'satrac9dec.c. Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-15T11:39:03Z.
Thanks for rebasing and for the libm fix. I had only built the new test on Windows, where the maths functions come from the C runtime; I'll build new test executables on Linux as well before opening PRs.
AI-assisted: yes (Claude Code).