Files
Shipwright/soh/src/code
Paul Schwabauer b6bf97e2f1 Fix ADPCM sample buffer overread in audio synthesis (#6364)
The sampleDataStartPad and aligned variables existed solely to satisfy
the N64 RSP DMA requirement that source addresses be 16-byte aligned.
On PC, aLoadBuffer is a plain memcpy with no such constraint.

The alignment dance caused aLoadBuffer to read up to 15 bytes before
sampleData and up to 8+ bytes past the end of the sample buffer. On
platforms with strict allocator guard pages (e.g. OpenBSD), this
triggers a SIGSEGV.

A second issue remains after removing the alignment dance: nFramesToDecode
is derived from sample counts (loopEnd), but size is not always a multiple
of frameSize. loopEnd and size are derived independently during encoding
and can disagree on the final partial frame, leaving nFramesToDecode *
frameSize exceeding the remaining bytes in the buffer.

Remove sampleDataStartPad and aligned entirely. Clamp the load to
min(nFramesToDecode * frameSize, audioFontSample->size - sampleDataOffset).
The ADPCM decoder operates on DMEM, so a partial last frame in DMEM
produces at most a negligible artifact at sound termination.
2026-03-21 18:34:18 +00:00
..
2026-01-10 21:31:21 +00:00
2023-01-17 00:33:56 -05:00
2025-04-01 22:33:38 -04:00
2024-11-11 17:46:25 -07:00
2024-11-11 17:46:25 -07:00
2022-07-25 21:11:53 -04:00
2025-04-01 22:33:38 -04:00
2025-04-01 22:33:38 -04:00
2026-01-18 16:01:39 +00:00
2025-04-01 22:33:38 -04:00
2025-04-01 22:33:38 -04:00
2025-04-01 22:33:38 -04:00
2026-01-10 21:31:21 +00:00
2024-11-11 17:46:25 -07:00
2026-03-17 04:53:33 +00:00
2025-04-01 22:33:38 -04:00
2024-04-21 10:25:06 -05:00
2025-04-01 22:33:38 -04:00
2026-02-28 23:51:13 +00:00
2025-04-01 22:33:38 -04:00
2026-03-17 04:53:33 +00:00
2026-03-17 04:53:33 +00:00
2025-04-01 22:33:38 -04:00
2025-03-30 12:29:59 -04:00
2024-11-08 20:36:57 -07:00
2025-04-01 22:33:38 -04:00
2025-04-01 22:33:38 -04:00
2025-04-01 22:33:38 -04:00
2025-04-01 22:33:38 -04:00
2026-03-17 04:53:33 +00:00
2025-04-01 22:33:38 -04:00