diff mbox series

[FFmpeg-devel,9/9] avformat/vividas: better check of current_sb_entry

Message ID 20201021223733.2563-9-michael@niedermayer.cc
State Accepted
Commit b848baef0dc42d97a5c1ab975cc8994a265b88ae
Headers show
Series [FFmpeg-devel,1/9] avformat/segafilm: Check that there is a stream | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Oct. 21, 2020, 10:37 p.m. UTC
This is the simplest fix for the problem, it is possible to instead check
this when the variables are set and propagate errors and then fail earlier

Fixes: out of array access
Fixes: 26490/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5723367078100992

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/vividas.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index 6e93d96aef..83d0ed1167 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -673,6 +673,10 @@  static int viv_read_packet(AVFormatContext *s,
     if (!pb)
         return AVERROR(EIO);
     off = avio_tell(pb);
+
+    if (viv->current_sb_entry >= viv->n_sb_entries)
+        return AVERROR_INVALIDDATA;
+
     off += viv->sb_entries[viv->current_sb_entry].size;
 
     if (viv->sb_entries[viv->current_sb_entry].flag == 0) {