fix(libSceAudioOut): validate the debug state id and size in sceAudioOut2SetSystemDebugState #9838
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9838"
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 JAB-dev on 2026-10-22T17:00:02Z.
What
sceAudioOut2SetSystemDebugStatenow accepts only the debug state the console accepts instead of every id with any size. The loudness state (id 1, an 8-byte param) still returns 0. Any other id, and id 1 with another size, returns0x80268001(invalid param), and a null pointer returns0x8026800C(invalid pointer; the repo returned0x80260502, which is not an AudioOut2 error code). The console also accepts id0x20with a 4-byte param, which the SDK does not document; that case throws, as does a loudness param whose data pointer is null (the console reads the loudness mode from it unchecked).Source: the PS5 SDK defines
SCE_AUDIO_OUT2_DEBUG_STATE_ID_LOUDNESSas 1,SceAudioOut2SystemDebugStateLoudnessParamas the loudness param (a mode and flags, 8 bytes) andSceAudioOut2SystemDebugStateParamas the debug state struct (debugStateIdat +0,parampointer at +8,paramSizeat +0x10), and declaressceAudioOut2SetSystemDebugState(const SceAudioOut2SystemDebugStateParam *debugStateParam)(audio_out2.h). In PS5 firmware 3.20 and 4.03,sceAudioOut2SetSystemDebugStatechecks the null pointer, then the id, then the size, and forwards the loudness mode. 4.03 has the same checks plus the id0x20with size 4 case. Both return0x80268001for any other id or size.The not-initialized error (
0x80268006) that the console checks first is not modelled becausesceAudioOut2Initializekeeps no state onmain.Tested
Windows 11 x64, MinGW GCC 15.2.0 (WinLibs r7), Release,
-DBUILD_TESTING=ON, onmain8499ea52e5.audio_out2_latency(existing test,TestSetSystemDebugStaterewritten):{id 1, 8 bytes}returns 0 twice; id 1 with sizes 0, 4 and 16 and ids 0, 2, 0x21 and 0xFFFFFFFF with size 8 return0x80268001; id0x20with sizes 8 and 0 returns0x80268001; id0x20with size 4 and id 1 with a null param throw; a null pointer returns0x8026800C. The expected codes are literal SDK values.AudioOut2System.cppfrommainand the new test kept,audio_out2_latencyaborts (exit code 0xc0000409): id 1 with size 0 is accepted (returns 0) where0x80268001is expected. With the change it passes. The old test passed an id 1 param with size 0 and expected 0, which the console refuses.python tools/check_conventions.py --base origin/mainpasses andgit diff --checkis clean.Linux not tested.
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