From 7ff394e1ecab504a4cb0fda4bd0f25d88ee4f6fe Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Mon, 14 Jul 2025 21:54:35 +0200 Subject: [PATCH] avformat/flvdec: don't skip backwards or at EOF --- libavformat/flvdec.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index b90ed34b1c..de5e688822 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -1860,8 +1860,16 @@ retry_duration: next_track: if (track_size) { av_log(s, AV_LOG_WARNING, "Track size mismatch: %d!\n", track_size); - avio_skip(s->pb, track_size); - size -= track_size; + if (!avio_feof(s->pb)) { + if (track_size > 0) { + avio_skip(s->pb, track_size); + size -= track_size; + } else { + /* We have somehow read more than the track had to offer, leave and re-sync */ + ret = FFERROR_REDO; + goto leave; + } + } } if (!size) -- 2.49.0