[FFmpeg-cvslog] avformat/matroskadec: Check parents remaining length

Steve Lhomme git at videolan.org
Sun Feb 17 11:53:03 EET 2019


ffmpeg | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Feb 13 13:20:45 2019 +0100| [9326117bf63b04a466d9e787224e56ba8cdbb215] | committer: Michael Niedermayer

avformat/matroskadec: Check parents remaining length

This was found through the Hacker One program on VLC but is not a security issue in libavformat
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/matroskadec.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index d7881d9c1d..5aa8a105dc 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1197,6 +1197,18 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
                    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) {



More information about the ffmpeg-cvslog mailing list