[FFmpeg-cvslog] avformat/mov: ensure all items id referenced by a grid are valid

James Almer git at videolan.org
Tue Apr 2 03:15:19 EEST 2024


ffmpeg | branch: release/7.0 | James Almer <jamrial at gmail.com> | Mon Apr  1 21:13:04 2024 -0300| [2ecaef745556684ba3d446994a570214e6fac7ce] | committer: James Almer

avformat/mov: ensure all items id referenced by a grid are valid

Fixes: null pointer dereference
Fixes: 67494/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6528714521247744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2ecaef745556684ba3d446994a570214e6fac7ce
---

 libavformat/mov.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index c93a09d385..917a69fa34 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -9396,8 +9396,9 @@ static int mov_parse_tiles(AVFormatContext *s)
 
         for (int j = 0; j < grid->nb_tiles; j++) {
             int tile_id = grid->tile_id_list[j];
+            int k;
 
-            for (int k = 0; k < mov->nb_heif_item; k++) {
+            for (k = 0; k < mov->nb_heif_item; k++) {
                 HEIFItem *item = &mov->heif_item[k];
                 AVStream *st = item->st;
 
@@ -9423,6 +9424,13 @@ static int mov_parse_tiles(AVFormatContext *s)
                 break;
             }
 
+            if (k == grid->nb_tiles) {
+                av_log(s, AV_LOG_WARNING, "HEIF item id %d referenced by grid id %d doesn't "
+                                          "exist\n",
+                       tile_id, grid->item->item_id);
+                ff_remove_stream_group(s, stg);
+                loop = 0;
+            }
             if (!loop)
                 break;
         }



More information about the ffmpeg-cvslog mailing list