From 2b82e33f4be460e7fa8b2f5ba0e610b671b850d7 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 19 Jul 2024 23:19:52 +0200 Subject: [PATCH] avcodec/cfhdenc: Height of 16 is not supported Fixes: out of array access Fixes: 68941/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5990952685600768 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit 5dde255abdeb50aefb0dcf8b060277e37d180ec6) Signed-off-by: Michael Niedermayer --- libavcodec/cfhdenc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c index 24dbe95a7d..b5af44505f 100644 --- a/libavcodec/cfhdenc.c +++ b/libavcodec/cfhdenc.c @@ -258,6 +258,11 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx) if (ret < 0) return ret; + if (avctx->height < 32) { + av_log(avctx, AV_LOG_ERROR, "Height must be >= 32.\n"); + return AVERROR_INVALIDDATA; + } + if (avctx->width & 15) { av_log(avctx, AV_LOG_ERROR, "Width must be multiple of 16.\n"); return AVERROR_INVALIDDATA;