ffmpeg/libavcodec/aac
Lynne 274064a5c7
aacdec_usac: use RefStruct to track unfinished extension buffers
Extensions in AAC USAC can be stored across multiple frames (mainly to keep CBR compliance).
This means that we need to reallocate a buffer when new data is received, accumulate the bitstream data,
and so on until the end of extension flag is signalled and the extension can be decoded.

This is made more complicated by the way in which the AAC channel layout switching is performed.
After decades of evolution, our AAC decoder evolved to double-buffer its entire configuration.
All changes are buffered, verified, and applied, on a per-frame basis if required, in often
random order.

Since we allocate the extension data on heap, this means that if configuration is applied,
in order to avoid double-freeing, we have to keep track of what we've allocated.

It should be noted that extensions which are spread in multiple frames are generally rare,
so an optimization to introduce av_refstruct_realloc() wouldn't generally be useful across the codebase.
Therefore, a copy is good enough for now.

Thanks to Michael Niedermayer for additional fixing.

Fixes: double free
Fixes: 393523547/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-6740617236905984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
(cherry picked from commit c05fc27dd3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-08 02:13:34 +02:00
..
aacdec.c aacdec_usac: use RefStruct to track unfinished extension buffers 2025-09-08 02:13:34 +02:00
aacdec.h aacdec_usac: use RefStruct to track unfinished extension buffers 2025-09-08 02:13:34 +02:00
aacdec_ac.c aacdec: add a decoder for AAC USAC (xHE-AAC) 2024-06-02 18:34:45 +02:00
aacdec_ac.h aacdec_ac: fix an overread 2024-06-21 10:50:21 +02:00
aacdec_dsp_template.c aacdec: add a decoder for AAC USAC (xHE-AAC) 2024-06-02 18:34:45 +02:00
aacdec_fixed.c aacdec_dsp: implement 768-point transform and windowing 2024-06-02 18:34:44 +02:00
aacdec_fixed_coupling.h aacdec: move aacdec.h into libavcodec/aac 2024-04-23 08:31:40 +02:00
aacdec_fixed_dequant.h aacdec: move spectrum decode and dequantization to a new file 2024-04-23 08:31:35 +02:00
aacdec_fixed_prediction.h aacdec: move prediction to separate files 2024-04-23 08:31:37 +02:00
aacdec_float.c aacdec_dsp: implement 768-point transform and windowing 2024-06-02 18:34:44 +02:00
aacdec_float_coupling.h aacdec: move aacdec.h into libavcodec/aac 2024-04-23 08:31:40 +02:00
aacdec_float_prediction.h aacdec: move prediction to separate files 2024-04-23 08:31:37 +02:00
aacdec_latm.h aacdec: add a decoder for AAC USAC (xHE-AAC) 2024-06-02 18:34:45 +02:00
aacdec_lpd.c avcodec/aac/aacdec_lpd: Limit get_unary() 2025-02-26 01:26:33 +01:00
aacdec_lpd.h aacdec: add a decoder for AAC USAC (xHE-AAC) 2024-06-02 18:34:45 +02:00
aacdec_proc_template.c avcodec/aac/aacdec: Fix linking errors with only one decoder enabled 2024-05-07 12:33:50 +02:00
aacdec_tab.c
aacdec_tab.h
aacdec_usac.c aacdec_usac: use RefStruct to track unfinished extension buffers 2025-09-08 02:13:34 +02:00
aacdec_usac.h aacdec: add a decoder for AAC USAC (xHE-AAC) 2024-06-02 18:34:45 +02:00
Makefile aacdec: add a decoder for AAC USAC (xHE-AAC) 2024-06-02 18:34:45 +02:00