PR #25945 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25945
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25945.patch


>From 5f5a126850d0f9130ee18d69dbfe99855f16331a Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 11 Nov 2026 15:22:27 +0100
Subject: [PATCH 1/4] avcodec/huffyuvenc: require all luma rows the median
 predictor reads

Fixes: out of array read
Fixes: dx18scXFJJxI

Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25573

Out of array read Replicated through UnModified FFmpeg with ASAN
Out of array read Replicated through API with ASAN
---
 libavcodec/huffyuvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 07195576671..d18c835c6b4 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -372,7 +372,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
     if (s->predictor == MEDIAN && s->version <= 2 &&
         (avctx->width < 4 ||
-         AV_CEIL_RSHIFT(avctx->height, s->chroma_v_shift) < 2 + 
s->interlaced)) {
+         avctx->height < (2 + s->interlaced) << s->chroma_v_shift)) {
         av_log(avctx, AV_LOG_ERROR, "Frame too small for the median 
predictor\n");
         return AVERROR(EINVAL);
     }
-- 
2.54.0


>From 852d47a6bc2a46d326f8f07450d4faa08affdd5b Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 11 Nov 2026 04:49:02 +0100
Subject: [PATCH 2/4] avcodec/vvc/dec: limit the slices of a picture to
 VVC_MAX_SLICES

Fixes: excessive memory allocation
Fixes: yGiQvHbsEdXd

Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25491
---
 libavcodec/vvc/dec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index f69fa99c6d6..b2dcc853ac5 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -953,6 +953,9 @@ static int decode_slice(VVCContext *s, VVCFrameContext *fc, 
AVBufferRef *buf_ref
     SliceContext *sc;
     const int is_first_slice = !fc->nb_slices;
 
+    if (fc->nb_slices >= VVC_MAX_SLICES)
+        return AVERROR_INVALIDDATA;
+
     ret = slices_realloc(fc);
     if (ret < 0)
         return ret;
-- 
2.54.0


>From b4d5ad47502cca61be3061f5f44f7b9321317039 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 11 Nov 2026 05:09:41 +0100
Subject: [PATCH 3/4] avcodec/mjpegdec: reject lossless RCT scans that do not
 code all components

Fixes: use of uninitialized memory
Fixes: fFQc8EgXP8v9

Found during the triage of a finding from the review of 
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25034

Use of uninitialized memory Replicated through UnModified FFmpeg with Valgrind
---
 libavcodec/mjpegdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index df46b2b8dc6..caa6b9d1d9c 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1120,6 +1120,8 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s)
         if (s->rct || s->pegasus_rct)
             return AVERROR_INVALIDDATA;
     }
+    if ((s->rct || s->pegasus_rct) && nb_components != s->nb_components)
+        return AVERROR_INVALIDDATA;
 
     av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
                    (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
-- 
2.54.0


>From 4d97dff53d66f97c48ae8c03c359027b3393a96b Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 11 Nov 2026 05:09:41 +0100
Subject: [PATCH 4/4] avcodec/ttaenc: reject sample rates the frame size
 computation overflows with

The decoder rejects the same sample rates.

Fixes: signed integer overflow: 256 * 9000000 cannot be represented in type 
'int'
Fixes: LbmS1VxBslMA

Found during the triage of a finding from the review of 
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25694

Signed integer overflow Replicated through UnModified FFmpeg with UBSAN
---
 libavcodec/ttaenc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/ttaenc.c b/libavcodec/ttaenc.c
index 4bef53a20f7..00936863a82 100644
--- a/libavcodec/ttaenc.c
+++ b/libavcodec/ttaenc.c
@@ -54,6 +54,11 @@ static av_cold int tta_encode_init(AVCodecContext *avctx)
         avctx->bits_per_raw_sample = 24;
     }
 
+    if (avctx->sample_rate > 0x7FFFFF) {
+        av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n");
+        return AVERROR(EINVAL);
+    }
+
     s->bps = avctx->bits_per_raw_sample >> 3;
     avctx->frame_size = 256 * avctx->sample_rate / 245;
 
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to