mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
The Smacker header declares a max audio chunk size, and libsmacker sized its output buffer from it — then wrote each frame's audio trusting the frame's own unpacked size, unchecked. The fan-localized intro videos (Chinese among others) declare max_buffer=2304 but carry ~97KB audio frames: every decode was a heap overflow, crashing the intro. The original SMACKW32.DLL played these files, so treat the per-frame size as truth and grow the buffer, bounded by a 16MB sanity cap; a chunk beyond that fails the frame as corrupt. Covers both the raw-PCM and DPCM paths. Verified with an ASan/UBSan harness over all 19 vanilla and Chinese intro SMKs: previously all 8 Chinese files faulted, now all decode both passes clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>