PR #25955 opened by trevorHansen URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25955 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25955.patch
Two AAC decoder inputs make AVERROR_BUG reach the caller, where the decode fuzzer's av_assert0(ret != AVERROR_BUG) aborts. Both are invalid input rather than internal bugs. 1. The error-resilient output path (aac_decode_er_frame) sets the output frame's sample rate from avctx->sample_rate without checking it is positive, unlike the general-audio path. AAC declares AV_CODEC_CAP_CHANNEL_CONF, so avcodec_open2() accepts a context with no sample rate; an ER configuration that never sets one then outputs a frame with sample_rate 0, which frame_validate() turns into AVERROR_BUG. This adds the same check the general-audio path already uses. 2. decode_ics_info() looks up the LD/ELD scalefactor-band tables with ff_aac_num_swb_480/512[sampling_index]; these are 0 for the sampling indices LD/ELD do not define, and the function returned AVERROR_BUG. It now returns AVERROR_INVALIDDATA. Both affect the aac and aac_fixed decoders; found with their OSS fuzzers. Same theme as the init() checks in #25954 and the merged misc4 (32eb07bb83) / nellymoser (23918b3200) fixes, but here in the frame/header path since AAC resolves its sample rate per frame. >From 4c6c95ccd9315d4e5d6c4f5219a869a2242cc6ef Mon Sep 17 00:00:00 2001 From: Trevor Hansen <[email protected]> Date: Thu, 12 Nov 2026 10:13:38 +1100 Subject: [PATCH 1/2] avcodec/aac: reject a non-positive sample rate in the ER frame path The error-resilient output path in aac/aacdec.c sets the output frame's sample rate from avctx->sample_rate without first checking it is positive, unlike the general-audio path which already rejects avctx->sample_rate <= 0 before outputting a frame. AAC declares AV_CODEC_CAP_CHANNEL_CONF, so avcodec_open2() accepts a context with no sample rate, and an ER configuration that never sets one then outputs a frame whose sample rate is 0, which frame_validate() rejects with AVERROR_BUG (and which trips the av_assert0() in the decode fuzzer). Add the same check the general-audio path uses, with the same message and error code. Signed-off-by: Trevor Hansen <[email protected]> --- libavcodec/aac/aacdec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index ba167eaab78..d8a738fea35 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -2338,6 +2338,12 @@ static int aac_decode_er_frame(AVCodecContext *avctx, AVFrame *frame, spectral_to_sample(ac, samples); + if (samples && avctx->sample_rate <= 0) { + av_log(avctx, AV_LOG_ERROR, + "Cannot output a frame without a valid sample rate\n"); + return AVERROR_INVALIDDATA; + } + if (!ac->frame->data[0] && samples) { av_log(avctx, AV_LOG_ERROR, "no frame data found\n"); return AVERROR_INVALIDDATA; -- 2.54.0 >From 05c40399cec90ab33e54a4d417335b221a6d8050 Mon Sep 17 00:00:00 2001 From: Trevor Hansen <[email protected]> Date: Thu, 12 Nov 2026 10:19:45 +1100 Subject: [PATCH 2/2] avcodec/aac: return AVERROR_INVALIDDATA for an unsupported LD/ELD sample rate index For ER AAC LD and ELD, decode_ics_info() reads the scalefactor-band tables with ff_aac_num_swb_480/512[sampling_index] (and the matching swb_offset tables). These entries are 0 for the sampling indices that LD and ELD do not define, and the function then returned AVERROR_BUG, which propagates out of avcodec_send_packet() and trips the av_assert0(ret != AVERROR_BUG) in the decode fuzzer. An unsupported sampling index in the bitstream is invalid input, not an internal bug. Return AVERROR_INVALIDDATA (the default for this function's failure path) and log it. Signed-off-by: Trevor Hansen <[email protected]> --- libavcodec/aac/aacdec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index d8a738fea35..7cbdf5647c2 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1508,7 +1508,9 @@ static int decode_ics_info(AACDecContext *ac, IndividualChannelStream *ics, ics->tns_max_bands = ff_tns_max_bands_512[sampling_index]; } if (!ics->num_swb || !ics->swb_offset) { - ret_fail = AVERROR_BUG; + av_log(ac->avctx, AV_LOG_ERROR, + "Unsupported sample rate index %d for LD/ELD\n", + sampling_index); goto fail; } } else { -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
