diff mbox series

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

Message ID 20220613001021.8065-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/3] tools/target_dec_fuzzer: Adjust threshold for SIMBIOSIS_IMX | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer June 13, 2022, 12:10 a.m. UTC
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@niedermayer.cc>
---
 libavformat/mov.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

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.