diff mbox series

[FFmpeg-devel,02/26] avformat/matroskadec: Fix handling gigantic durations

Message ID 20200614223656.21338-2-andreas.rheinhardt@gmail.com
State Accepted
Commit 3714d452b894821591a2fbafdd1b8ef15abe4be6
Headers show
Series [FFmpeg-devel,01/26] avformat/matroskadec: Move AVBufferRef instead of copying, fix memleak
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt June 14, 2020, 10:36 p.m. UTC
matroska_parse_block currently asserts that the duration is not equal to
AV_NOPTS_VALUE, but there is nothing that actually guarantees this. It
is easy to create (spec-compliant) files which run into this assert;
so replace it and instead cap the duration to INT64_MAX, as the duration
field of an AVPacket is an int64_t.

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

Patch

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index b1da40983f..1846b1f93c 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3568,7 +3568,8 @@  static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf
 
     if (st->discard >= AVDISCARD_ALL)
         return res;
-    av_assert1(block_duration != AV_NOPTS_VALUE);
+    if (block_duration > INT64_MAX)
+        block_duration = INT64_MAX;
 
     block_time = sign_extend(AV_RB16(data), 16);
     data      += 2;