From 7b660aa875dcedaca8cf01066a7f03e3ef9ccdb5 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 29 Jan 2021 21:18:36 +0100 Subject: [PATCH] avformat/matroskadec: Check for EOF in resync loop Fixes: Timeout (too long -> instantly) Fixes: 29136/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-4586141227548672 Reviewed-by: Andreas Rheinhardt Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit 5282147d0c92ac821e85b93e2db6704f4720e0c1) Signed-off-by: Michael Niedermayer --- libavformat/matroskadec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 98913dfdb6..5a83e8af89 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2653,6 +2653,8 @@ static int matroska_read_header(AVFormatContext *s) goto fail; pos = avio_tell(matroska->ctx->pb); res = ebml_parse(matroska, matroska_segment, matroska); + if (res == AVERROR(EIO)) // EOF is translated to EIO, this exists the loop on EOF + goto fail; } matroska_execute_seekhead(matroska);