diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2020-09-09 23:13:02 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-11-28 00:41:51 +0100 |
commit | 81503ac58a763a36b1f57264013b1e76acb62b68 (patch) | |
tree | 995710da182b6cabc55c1daa764a69120d0618cb /libavcodec/utils.c | |
parent | 34f5a59ad5aa8baad2036321f63bf1e34ffdefb9 (diff) | |
download | ffmpeg-81503ac58a763a36b1f57264013b1e76acb62b68.tar.gz |
avcodec/utils: Require a non zero channels unless AV_CODEC_CAP_CHANNEL_CONF is set
This avoids per codec checks for channels not being 0
Fixes: division by 0
Fixes: 25419/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FASTAUDIO_fuzzer-5632544761184256
Fixes: 25433/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FASTAUDIO_fuzzer-6215671900536832
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Suggested-by: Paul B Mahol <onemda@gmail.com>
See: [FFmpeg-devel] [PATCH 1/3] avcodec/fastaudio: Check channel
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 3232a242c0..45295dd3ce 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -667,6 +667,15 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code ret = AVERROR(EINVAL); goto free_and_end; } + if (av_codec_is_decoder(codec) && + codec->type == AVMEDIA_TYPE_AUDIO && + !(codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF) && + avctx->channels == 0) { + av_log(avctx, AV_LOG_ERROR, "Decoder requires channel count but channels not set\n"); + ret = AVERROR(EINVAL); + goto free_and_end; + } + if (avctx->sample_rate < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate); ret = AVERROR(EINVAL); |