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

# Summary of changes

Briefly describe what this PR does and why.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From 41ffb2765d832478c19267484aee8b71873bfe3d Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Tue, 17 Nov 2026 00:34:44 +0100
Subject: [PATCH 1/5] avcodec/hevc/hevcdec: reject slices of a picture that is
 not the current one

NULL pointer dereference Replicated through UnModified FFmpeg with ASAN

Fixes: NULL pointer dereference
Fixes: 
580179382/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5261322888216576
Fixes: 
580320486/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6478957072154624
Fixes: SP0JBx1mfohj
Regression since: eedf8f0165fe6523be692c5a91ebf6744808335d

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/hevc/hevcdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 0934f640966..0f459c5c1f4 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -4431,7 +4431,7 @@ static int decode_slice(HEVCContext *s, unsigned nal_idx, 
GetBitContext *gb)
         ret = hevc_frame_start(s, l, nal_idx);
         if (ret < 0)
             return ret;
-    } else if (!l->cur_frame) {
+    } else if (!l->cur_frame || l->cur_frame != s->cur_frame) {
         av_log(s->avctx, AV_LOG_ERROR, "First slice in a frame missing.\n");
         return AVERROR_INVALIDDATA;
     }
-- 
2.54.0


>From 19b8f06c92476a9a602d5270e35e5ef17d6ff3b6 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Tue, 17 Nov 2026 00:34:52 +0100
Subject: [PATCH 2/5] avcodec/aom_film_grain: do not apply chroma grain to
 frames without chroma

NULL pointer dereference Replicated through UnModified FFmpeg with ASAN

Fixes: NULL pointer dereference
Fixes: 
583284275/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6553010445287424
Fixes: 
583493829/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4542557191995392
Fixes: rcYbsa3hpgAg
Regression since: 14746871e1d33de172d6cb32730d962068e3ccd2

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/aom_film_grain_template.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/aom_film_grain_template.c 
b/libavcodec/aom_film_grain_template.c
index 5f9f29f1fab..b98639c6ca9 100644
--- a/libavcodec/aom_film_grain_template.c
+++ b/libavcodec/aom_film_grain_template.c
@@ -507,7 +507,8 @@ FUNC(apply_grain_row)(AVFrame *out, const AVFrame *in,
                             grain_lut[0], bh, row HBD_CALL);
     }
 
-    if (!data->num_uv_points[0] && !data->num_uv_points[1] &&
+    if (!out->data[1] ||
+        !data->num_uv_points[0] && !data->num_uv_points[1] &&
         !data->chroma_scaling_from_luma)
     {
         return;
-- 
2.54.0


>From fb813d3786475a787a3b96b0ab6f79f7746487c3 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Tue, 17 Nov 2026 00:34:58 +0100
Subject: [PATCH 3/5] avformat/ogg/mapping/theora: handle packets of a stream
 without parsed headers

NULL pointer dereference Replicated through UnModified FFmpeg with ASAN

Fixes: NULL pointer dereference
Fixes: 
586059034/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5205241184976896
Fixes: 0Dvf25pzuAPd
Regression since: efae53645158208f65f4d9a5dce95712819639c0

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavformat/ogg/mapping/theora.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/ogg/mapping/theora.c b/libavformat/ogg/mapping/theora.c
index b720de45fba..58de1fcf1d8 100644
--- a/libavformat/ogg/mapping/theora.c
+++ b/libavformat/ogg/mapping/theora.c
@@ -277,7 +277,7 @@ static int theora_packet(AVFormatContext *s, int idx)
     /* A later link's headers are skipped and attached as extradata to the
      * first data packet that follows. That packet keeps its timestamp, which
      * ogg_read_packet() would clear after a stream replacement. */
-    if (type != THEORA_PACKET_DATA && type != THEORA_PACKET_RESERVED) {
+    if (thp && type != THEORA_PACKET_DATA && type != THEORA_PACKET_RESERVED) {
         int i = type - THEORA_PACKET_ID;
 
         os->replace = 0;
@@ -312,7 +312,8 @@ static int theora_packet(AVFormatContext *s, int idx)
 
         return 1;
     }
-    theora_check_packet_order(s, thp, type);
+    if (thp)
+        theora_check_packet_order(s, thp, type);
 
     /* first packet handling
        here we parse the duration of each packet in the first page and compare
-- 
2.54.0


>From 265c5957757e261d927a95b21cd681073a013036 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Tue, 17 Nov 2026 00:35:07 +0100
Subject: [PATCH 4/5] avformat/iamf_reader: reject parameter blocks with more
 subblocks than bytes

Subblocks beyond the end of the OBU were read as zeros, the resulting
parameters are attached to every audio packet.

Out of memory Replicated through API

Fixes: OOM
Fixes: 
579141633/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6145767199539200
Fixes: It1CcPzF1iT8

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavformat/iamf_reader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/iamf_reader.c b/libavformat/iamf_reader.c
index c2375ea8356..4f409a706d9 100644
--- a/libavformat/iamf_reader.c
+++ b/libavformat/iamf_reader.c
@@ -176,7 +176,7 @@ static int parameter_block_obu(AVFormatContext *s, 
IAMFDemuxContext *c,
         nb_subblocks = param->nb_subblocks;
     }
 
-    if (nb_subblocks > duration) {
+    if (nb_subblocks > duration || nb_subblocks > len) {
         av_log(s, AV_LOG_ERROR, "Invalid duration or subblock count in 
parameter_id %u\n", parameter_id);
         ret = AVERROR_INVALIDDATA;
         goto fail;
-- 
2.54.0


>From 6733e17843e4bfbb56a2e711f0dd6ad4402b10fc Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Tue, 17 Nov 2026 00:35:13 +0100
Subject: [PATCH 5/5] avformat/mov: grow the buffer of discarded frame
 durations geometrically

Timeout Replicated through API

Fixes: Timeout
Fixes: 
583599147/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5690659563175936
Fixes: 2vgyxUjJ1Nn1

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavformat/mov.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index eba7619ed14..124b527e0ce 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4738,13 +4738,12 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
                     av_log(mov->fc, AV_LOG_DEBUG, "drop a frame at curr_cts: 
%"PRId64" @ %"PRId64"\n", curr_cts, index);
 
                     if (edit_list_start_encountered == 0) {
-                        num_discarded_begin++;
-                        if (av_reallocp_array(&frame_duration_buffer, 
num_discarded_begin,
-                                              sizeof(*frame_duration_buffer)) 
< 0) {
+                        if (!av_dynarray2_add((void **)&frame_duration_buffer, 
&num_discarded_begin,
+                                              sizeof(*frame_duration_buffer),
+                                              (const uint8_t 
*)&frame_duration)) {
                             av_log(mov->fc, AV_LOG_ERROR, "Cannot reallocate 
frame duration buffer\n");
                             break;
                         }
-                        frame_duration_buffer[num_discarded_begin - 1] = 
frame_duration;
 
                         // Increment skip_samples for the first non-zero audio 
edit list
                         if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
-- 
2.54.0

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

Reply via email to