1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

avformat/hls: reject Master Playlist tags in a Media Playlist

Fixes infinite loop on crafted HLS playlists.

Fixes: recursion.m3u8
Fixes: cEy2cxyyPaLH
Fixes: cd223e0b4e (Add Apple HTTP Live Streaming demuxer)
Found-by: BapToutatis
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit c364ab176f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Kacper Michajłow
2026-06-27 17:43:33 +02:00
committed by Michael Niedermayer
parent 1f51b7b87f
commit 0e6eef3551

View File

@@ -890,6 +890,12 @@ static int parse_playlist(HLSContext *c, const char *url,
while (!avio_feof(in)) {
ff_get_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
if (pls) {
av_log(c->ctx, AV_LOG_ERROR,
"Master Playlist tag found in a Media Playlist\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
is_variant = 1;
memset(&variant_info, 0, sizeof(variant_info));
ff_parse_key_value(ptr, handle_variant_args, &variant_info);
@@ -909,6 +915,12 @@ static int parse_playlist(HLSContext *c, const char *url,
av_strlcpy(key, info.uri, sizeof(key));
} else if (av_strstart(line, "#EXT-X-MEDIA:", &ptr)) {
struct rendition_info info = {{0}};
if (pls) {
av_log(c->ctx, AV_LOG_ERROR,
"Master Playlist tag found in a Media Playlist\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
ff_parse_key_value(ptr, handle_rendition_args, &info);
new_rendition(c, &info, url);
} else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {