diff mbox

[FFmpeg-devel,33/37] avformat/matroskadec: Fix probing of unknown-length headers

Message ID 20190516223018.30827-34-andreas.rheinhardt@gmail.com
State Accepted
Commit 9c6d14ab84e424bdb99a1a4b499311ecf8687ceb
Headers show

Commit Message

Andreas Rheinhardt May 16, 2019, 10:30 p.m. UTC
matroska_probe did not support the case of an unknown-length EBML header
at all; given that libavformat's Matroska muxer used to produce such
files in the streaming case, support for them has been added.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/matroskadec.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 404e5005a7..edf21e5fe2 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1511,9 +1511,14 @@  static int matroska_probe(const AVProbeData *p)
     while (n < size)
         total = (total << 8) | p->buf[4 + n++];
 
-    /* Does the probe data contain the whole header? */
-    if (p->buf_size < 4 + size + total)
-        return 0;
+    if (total + 1 == 1ULL << (7 * size)){
+        /* Unknown-length header - simply parse the whole buffer. */
+        total = p->buf_size - 4 - size;
+    } else {
+        /* Does the probe data contain the whole header? */
+        if (p->buf_size < 4 + size + total)
+            return 0;
+    }
 
     /* The header should contain a known document type. For now,
      * we don't parse the whole header but simply check for the