[FFmpeg-cvslog] avformat/mpc8: Check first keyframe position for overflow

Michael Niedermayer git at videolan.org
Wed Sep 8 22:43:48 EEST 2021


ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Sun Aug  1 20:25:20 2021 +0200| [58477f42a2a7220bf412fbfd460c6fcc077396a5] | committer: Michael Niedermayer

avformat/mpc8: Check first keyframe position for overflow

Fixes: signed integer overflow: 9223372036854775791 + 18 cannot be represented in type 'long'
Fixes: 36307/clusterfuzz-testcase-minimized-ffmpeg_dem_MPC8_fuzzer-4917863877050368

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 2bbef69b0ba938cce4f9d61bed46d3f3058e56c2)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/mpc8.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c
index 95813df748..c3d7e115a7 100644
--- a/libavformat/mpc8.c
+++ b/libavformat/mpc8.c
@@ -177,7 +177,13 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
     }
     seekd = get_bits(&gb, 4);
     for(i = 0; i < 2; i++){
-        pos = gb_get_v(&gb) + c->header_pos;
+        pos = gb_get_v(&gb);
+        if (av_sat_add64(pos, c->header_pos) != pos + (uint64_t)c->header_pos) {
+            av_free(buf);
+            return;
+        }
+
+        pos += c->header_pos;
         ppos[1 - i] = pos;
         av_add_index_entry(s->streams[0], pos, i, 0, 0, AVINDEX_KEYFRAME);
     }



More information about the ffmpeg-cvslog mailing list