This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch release/8.1
in repository ffmpeg.

commit 3cd473d862149df958d8e0ceb10737d2baf92eb8
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Tue Feb 10 13:56:10 2026 +0100
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Sat Sep 19 16:59:28 2026 +0200

    avcodec/leaddec: Check input data before allocating buffer
    
    Fixes: Timeout
    Fixes: 
471636089/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LEAD_fuzzer-6346348464242688
    
    Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
    Signed-off-by: Michael Niedermayer <[email protected]>
    (cherry picked from commit a780d46d3bb3a09cb8d174edba144008c0af3b30)
---
 libavcodec/leaddec.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavcodec/leaddec.c b/libavcodec/leaddec.c
index e6a91faabc..e9974e8365 100644
--- a/libavcodec/leaddec.c
+++ b/libavcodec/leaddec.c
@@ -184,6 +184,15 @@ static int lead_decode_frame(AVCodecContext *avctx, 
AVFrame * frame,
     calc_dequant(dequant[0], ff_mjpeg_std_luminance_quant_tbl, q);
     calc_dequant(dequant[1], ff_mjpeg_std_chrominance_quant_tbl, q);
 
+    int mb_size_log2 = 4 - (avctx->pix_fmt == AV_PIX_FMT_YUV444P);
+    int blocks_per_mb = 2 + (1<<mb_size_log2)*(1<<mb_size_log2) / 64 - 
2*yuv20p_half;
+    // Check against a lower bound of the input bitstream size
+    // Each block has at least a dc and ac code
+    // The smallest DC and AC code are each 2 bit
+    // There are cases where a column at the right or row at the bottom cannot 
be encoded, these are disregarded in this check as they do not fulfill the 
contract of encoding width x height pixels. They are either unsupported by the 
format or our implementation is incorrect
+    if ((avpkt->size - 8LL) * 8 < AV_CEIL_RSHIFT(avctx->width, mb_size_log2) * 
AV_CEIL_RSHIFT(avctx->height, mb_size_log2) * blocks_per_mb * (2 + 2))
+        return AVERROR_INVALIDDATA;
+
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to