[vlc-commits] contrib:ffmpeg: don't use EBML elements in Matroska that are bigger than their parents

Steve Lhomme git at videolan.org
Thu May 23 17:40:21 CEST 2019


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Feb 11 16:06:50 2019 +0100| [acbdf89276a3fca4581156b3f2830fd7d140b8e2] | committer: Hugo Beauzée-Luyssen

contrib:ffmpeg: don't use EBML elements in Matroska that are bigger than their parents

https://hackerone.com/reports/492882

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
(cherry picked from commit 8cf800fdcf92af25838ab71d2bb7f819f5d19149)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=acbdf89276a3fca4581156b3f2830fd7d140b8e2
---

 contrib/src/ffmpeg/ffmpeg-mkv-overshoot.patch | 21 +++++++++++++++++++++
 contrib/src/ffmpeg/rules.mak                  |  1 +
 2 files changed, 22 insertions(+)

diff --git a/contrib/src/ffmpeg/ffmpeg-mkv-overshoot.patch b/contrib/src/ffmpeg/ffmpeg-mkv-overshoot.patch
new file mode 100644
index 0000000000..2ad31ca54a
--- /dev/null
+++ b/contrib/src/ffmpeg/ffmpeg-mkv-overshoot.patch
@@ -0,0 +1,21 @@
+--- ffmpeg/libavformat/matroskadec.c.overshoot	2019-02-11 16:03:57.375444600 +0100
++++ ffmpeg/libavformat/matroskadec.c	2019-02-11 16:04:04.418307200 +0100
+@@ -1197,6 +1197,18 @@ static int ebml_parse_elem(MatroskaDemux
+                    length, max_lengths[syntax->type], syntax->type);
+             return AVERROR_INVALIDDATA;
+         }
++        if (matroska->num_levels > 0) {
++            MatroskaLevel *level = &matroska->levels[matroska->num_levels - 1];
++            AVIOContext *pb = matroska->ctx->pb;
++            int64_t pos = avio_tell(pb);
++            if (level->length != (uint64_t) -1 &&
++                (pos + length) > (level->start + level->length)) {
++                av_log(matroska->ctx, AV_LOG_ERROR,
++                       "Invalid length 0x%"PRIx64" > 0x%"PRIx64" in parent\n",
++                       length, level->start + level->length);
++                return AVERROR_INVALIDDATA;
++            }
++        }
+     }
+ 
+     switch (syntax->type) {
diff --git a/contrib/src/ffmpeg/rules.mak b/contrib/src/ffmpeg/rules.mak
index ed5ea79b55..de63a08b1b 100644
--- a/contrib/src/ffmpeg/rules.mak
+++ b/contrib/src/ffmpeg/rules.mak
@@ -241,6 +241,7 @@ ifdef USE_FFMPEG
 	$(APPLY) $(SRC)/ffmpeg/armv7_fixup.patch
 	$(APPLY) $(SRC)/ffmpeg/dxva_vc1_crash.patch
 	$(APPLY) $(SRC)/ffmpeg/h264_early_SAR.patch
+	$(APPLY) $(SRC)/ffmpeg/ffmpeg-mkv-overshoot.patch
 endif
 ifdef USE_LIBAV
 	$(APPLY) $(SRC)/ffmpeg/libav_gsm.patch



More information about the vlc-commits mailing list