From f76bd694c361d1ef7619528009efe043fc5df626 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 11 Aug 2026 03:56:32 +0200 Subject: [PATCH] avformat/hlsproto: reject NaN and out of range EXTINF Fixes: #EXTINF:nan and #EXTINF:1e300 --- libavformat/hlsproto.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/hlsproto.c b/libavformat/hlsproto.c index d0cd9e9fa4..906f1bbaf2 100644 --- a/libavformat/hlsproto.c +++ b/libavformat/hlsproto.c @@ -142,9 +142,13 @@ static int parse_playlist(URLContext *h, const char *url) } else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) { s->finished = 1; } else if (av_strstart(line, "#EXTINF:", &ptr)) { + double d = atof(ptr) * AV_TIME_BASE; + if (!(d >= 0 && d < INT64_MAX)) { + ret = AVERROR_INVALIDDATA; + goto fail; + } is_segment = 1; - duration = atof(ptr) * AV_TIME_BASE; - duration = FFMAX(duration, 0.001 * AV_TIME_BASE); + duration = FFMAX(d, 0.001 * AV_TIME_BASE); } else if (av_strstart(line, "#", NULL)) { continue; } else if (line[0]) {