[FFmpeg-cvslog] avformat/mxfdec: Check run_in is within 65536

Michael Niedermayer git at videolan.org
Mon Sep 26 01:24:35 EEST 2022


ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Sun Sep 18 14:28:03 2022 +0200| [0191e5f13e7a739fb4c3c6ba0cfeea95fdc80eb5] | committer: Michael Niedermayer

avformat/mxfdec: Check run_in is within 65536

Fixes: signed integer overflow: 9223372036854775807 - -2146905566 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6570996594769920

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 7786097825d9e3f02b4574c1924c28818eb83340)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

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

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 6ceaf9c3df..3384fc5c69 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -60,6 +60,7 @@
 #include "mxf.h"
 
 #define MXF_MAX_CHUNK_SIZE (32 << 20)
+#define RUN_IN_MAX (65535+1)  // S377m-2004 section 5.5 and S377-1-2009 section 6.5, the +1 is to be slightly more tolerant
 
 typedef enum {
     Header,
@@ -3357,6 +3358,7 @@ static int mxf_read_header(AVFormatContext *s)
     KLVPacket klv;
     int64_t essence_offset = 0;
     int ret;
+    int64_t run_in;
 
     mxf->last_forward_tell = INT64_MAX;
 
@@ -3367,7 +3369,10 @@ static int mxf_read_header(AVFormatContext *s)
     }
     avio_seek(s->pb, -14, SEEK_CUR);
     mxf->fc = s;
-    mxf->run_in = avio_tell(s->pb);
+    run_in = avio_tell(s->pb);
+    if (run_in < 0 || run_in > RUN_IN_MAX)
+        return AVERROR_INVALIDDATA;
+    mxf->run_in = run_in;
 
     mxf_read_random_index_pack(s);
 



More information about the ffmpeg-cvslog mailing list