[FFmpeg-devel] [PATCH 2/3] avformat/mov: Check the item count in iloc better

Michael Niedermayer michael at niedermayer.cc
Mon Jun 13 03:10:20 EEST 2022


Fixes: out of array access
Fixes: 47899/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5706852010164224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavformat/mov.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index fa471c45ea..3f7b0e3ed1 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7501,12 +7501,12 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         return AVERROR_PATCHWELCOME;
     }
     item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
-    if (item_count > 1) {
+    if (item_count != 1) {
         // For still AVIF images, we only support one item. Second item will
         // generally be found for AVIF images with alpha channel. We don't
         // support them as of now.
-        av_log(c->fc, AV_LOG_ERROR, "iloc: item_count > 1 not supported.\n");
-        return AVERROR_PATCHWELCOME;
+        av_log(c->fc, AV_LOG_ERROR, "iloc: item_count != 1 not supported.\n");
+        return item_count ? AVERROR_PATCHWELCOME : AVERROR_INVALIDDATA;
     }
 
     // Populate the necessary fields used by mov_build_index.
-- 
2.17.1



More information about the ffmpeg-devel mailing list