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

Found-by: Anthropic's OSS Scanner


>From 278fa310598c28080c00e407b8f213d29e35be87 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 18 Nov 2026 15:52:19 +0100
Subject: [PATCH 1/5] avcodec/apv_decode: do not start a further primary frame
 of a packet after ff_thread_finish_setup()

Fixes: out of array write
Fixes: zrDwkIvkDrGG
Fixes: ANT-2026-PUXQAX52
Regression since: 300cac3078
Found-by: Anthropic's OSS Scanner

Out of array write Replicated through UnModified FFmpeg with ASAN
---
 libavcodec/apv_decode.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/apv_decode.c b/libavcodec/apv_decode.c
index 19c24d293f4..799f7ddfebd 100644
--- a/libavcodec/apv_decode.c
+++ b/libavcodec/apv_decode.c
@@ -361,6 +361,12 @@ static int apv_decode(AVCodecContext *avctx, AVFrame 
*output,
     APVDerivedTileInfo           *tile_info = &apv->tile_info;
     int err, job_count;
 
+    if (!ff_thread_can_start_frame(avctx)) {
+        av_log(avctx, AV_LOG_ERROR, "Multiple primary frames in a packet "
+               "are not supported with frame threading.\n");
+        return AVERROR_PATCHWELCOME;
+    }
+
     err = apv_decode_check_format(avctx, &input->frame_header);
     if (err < 0) {
         av_log(avctx, AV_LOG_ERROR, "Unsupported format parameters.\n");
-- 
2.54.1


>From ea38e50c91e1a3fbe7e7f1de516b3e74228c72b9 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 18 Nov 2026 05:24:59 +0100
Subject: [PATCH 2/5] avcodec/cbs_h265: bound the number of decoding units when
 the SPS has no picture size

Fixes: out of array write
Fixes: UgwoO3TwWfCu
Fixes: ANT-2026-ZR7AO0XN
Regression since: 8864fd0aec
Found-by: Anthropic's OSS Scanner

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

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 1e03bdf63ee..cf4758fd1ef 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -1993,7 +1993,7 @@ SEI_FUNC(sei_pic_timing, (CodedBitstreamContext *ctx, 
RWContext *rw,
             // than HEVC_MAX_SLICE_SEGMENTS slice segments (A.4.2), which is 
also
             // the size of the arrays indexed by it.
             ue(num_decoding_units_minus1, 0,
-               FFMIN(pic_width_in_ctbs_y * pic_height_in_ctbs_y, 
HEVC_MAX_SLICE_SEGMENTS) - 1);
+               FFMIN(pic_width_in_ctbs_y * pic_height_in_ctbs_y - 1, 
HEVC_MAX_SLICE_SEGMENTS - 1));
             flag(du_common_cpb_removal_delay_flag);
 
             length = hrd->du_cpb_removal_delay_increment_length_minus1 + 1;
-- 
2.54.1


>From 87b28bf53afbea6fe3082e9bff4559590f8fa88c Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 18 Nov 2026 15:52:19 +0100
Subject: [PATCH 3/5] avformat/rtmppkt: forget the partially read message when
 reading a chunk's payload fails

Fixes: write to NULL + offset chosen by the peer
Fixes: 0Z6vel9moooT
Fixes: ANT-2026-EZ0OGW39
Found-by: Anthropic's OSS Scanner

Write to an address chosen by the peer Replicated through UnModified FFmpeg 
with ASAN
---
 libavformat/rtmppkt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 209ecd32570..73f68ded4e6 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -276,6 +276,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, 
RTMPPacket *p,
     toread = FFMIN(size, chunk_size);
     if (ffurl_read_complete(h, p->data + p->offset, toread) != toread) {
         ff_rtmp_packet_destroy(p);
+        prev_pkt[channel_id].read = 0;
         return AVERROR(EIO);
     }
     size      -= toread;
-- 
2.54.1


>From 199ab0a457349f43bd498415e3216c21763df729 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 18 Nov 2026 15:52:20 +0100
Subject: [PATCH 4/5] avcodec/cfhd: reject the FrameIndex frame request when
 the context's dimensions or pixel format differ from the allocated buffers

Fixes: out of array write
Fixes: zPJ4SItf22cl
Fixes: ANT-2026-JP43PTUO
Found-by: Anthropic's OSS Scanner

Out of array write Replicated through UnModified FFmpeg with ASAN
---
 libavcodec/cfhd.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 8033fac69db..f3a4ce820eb 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -695,6 +695,13 @@ static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic,
             s->coded_format = AV_PIX_FMT_NONE;
             got_buffer = 1;
         } else if (tag == FrameIndex && data == 1 && s->sample_type == 1 && 
s->frame_type == 2) {
+            if (avctx->coded_width  != s->a_width  ||
+                avctx->coded_height != s->a_height ||
+                avctx->pix_fmt      != s->a_format) {
+                av_log(avctx, AV_LOG_ERROR, "Frame parameters do not match the 
allocated buffers\n");
+                ret = AVERROR_INVALIDDATA;
+                goto end;
+            }
             pic->width = pic->height = 0;
 
             if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
-- 
2.54.1


>From c11ec0dbc7f95d287d5a4fcacccdc3207fb0f644 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 18 Nov 2026 15:52:20 +0100
Subject: [PATCH 5/5] avformat/rtpdec_av1: assemble the temporal unit in a
 packet of the PayloadContext instead of the caller's shared AVPacket

Fixes: out of array write
Fixes: lpyS49qp7Khk
Fixes: ANT-2026-8V3C20FG
Found-by: Anthropic's OSS Scanner

Out of array write Replicated through UnModified FFmpeg with ASAN
---
 libavformat/rtpdec_av1.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/libavformat/rtpdec_av1.c b/libavformat/rtpdec_av1.c
index a45a2f149d6..61d765488d0 100644
--- a/libavformat/rtpdec_av1.c
+++ b/libavformat/rtpdec_av1.c
@@ -44,6 +44,7 @@
  * RTP/AV1 specific private data.
  */
 struct PayloadContext {
+    AVPacket *pkt;      ///< temporal unit being assembled
     uint32_t timestamp; ///< last received timestamp for frame
     uint8_t profile;    ///< profile (main/high/professional)
     uint8_t level_idx;  ///< level (0-31)
@@ -78,9 +79,10 @@ static int sdp_parse_fmtp_config_av1(AVFormatContext *s,
 
 // return 0 on complete packet, -1 on partial packet
 static int av1_handle_packet(AVFormatContext *ctx, PayloadContext *data,
-                             AVStream *st, AVPacket *pkt, uint32_t *timestamp,
+                             AVStream *st, AVPacket *out_pkt, uint32_t 
*timestamp,
                              const uint8_t *buf, int len, uint16_t seq,
                              int flags) {
+    AVPacket *pkt = data->pkt;
     uint8_t aggr_hdr;
     int result = 0;
     int is_frag_cont;
@@ -398,6 +400,11 @@ static int av1_handle_packet(AVFormatContext *ctx, 
PayloadContext *data,
 #endif
     pkt->stream_index = st->index;
 
+    if (!result) {
+        av_packet_unref(out_pkt);
+        av_packet_move_ref(out_pkt, pkt);
+    }
+
     return result;
 
 drop_fragment:
@@ -413,7 +420,19 @@ drop_fragment:
     return AVERROR_INVALIDDATA;
 }
 
+static av_cold int av1_init(AVFormatContext *s, int st_index,
+                            PayloadContext *data)
+{
+    if (!data->pkt)
+        data->pkt = av_packet_alloc();
+    if (!data->pkt)
+        return AVERROR(ENOMEM);
+
+    return 0;
+}
+
 static void av1_close_context(PayloadContext *data) {
+    av_packet_free(&data->pkt);
 }
 
 static int av1_need_keyframe(PayloadContext *data)
@@ -450,6 +469,7 @@ const RTPDynamicProtocolHandler ff_av1_dynamic_handler = {
         .need_parsing     = AVSTREAM_PARSE_FULL,
         .priv_data_size   = sizeof(PayloadContext),
         .parse_sdp_a_line = parse_av1_sdp_line,
+        .init             = av1_init,
         .close            = av1_close_context,
         .parse_packet     = av1_handle_packet,
         .need_keyframe    = av1_need_keyframe,
-- 
2.54.1

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

Reply via email to