[FFmpeg-devel] [PATCH] avformat/mov: perform sanity checks for heif before index building

Michael Niedermayer michael at niedermayer.cc
Wed Jan 8 22:31:37 EET 2025


Fixes: undefined NULL pointer use
Fixes: clusterfuzz-testcase-minimized-audio_decoder_fuzzer-6363211175493632

This performs equivalent sanity checks as are done in mov_read_trak()
before mov_build_index()

Reported-by: Dale Curtis <dalecurtis at chromium.org>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavformat/mov.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 56f732bfcfb..33823b98b2f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -10411,6 +10411,10 @@ static int mov_parse_heif_items(AVFormatContext *s)
         if (sc->sample_count != 1 || sc->chunk_count != 1)
             return AVERROR_INVALIDDATA;
 
+            /* sanity checks */
+        if (!sc->stts_count || !sc->stsc_count)
+            return AVERROR_INVALIDDATA;
+
         sc->sample_sizes[0]  = item->extent_length;
         sc->chunk_offsets[0] = item->extent_offset + offset;
 
-- 
2.47.0



More information about the ffmpeg-devel mailing list