From patchwork Sat May 16 12:11:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 19710 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id BA4A2448D64 for ; Sat, 16 May 2020 15:12:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 970CC6898D5; Sat, 16 May 2020 15:12:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 829EF6804D5 for ; Sat, 16 May 2020 15:12:18 +0300 (EEST) X-QQ-mid: bizesmtp2t1589631119tfjd2b052 Received: from localhost (unknown [221.216.226.131]) by esmtp6.qq.com (ESMTP) with id ; Sat, 16 May 2020 20:11:58 +0800 (CST) X-QQ-SSF: 01100000000000Y0ZXF0B00A0000000 X-QQ-FEAT: BZmIBRFS1zvmWS/HQTdJF/nUTkYCczMbbbxjlcLNzKz36BKOgT4sifa96KAE2 VgPFPF6u9CshA18UFzDaq58FqWU3d4fmdHvklx/CeuFsk8qi2gkFww6G5E44ubL3aikXX5+ +AJE9omywT3Kdd9Kg8/rlm2aGMbkvjIeoy0Iw6vzSKjQXKKezED4s2qOtZd8TdfHFOtqW2t iIGTLJJZyve+fUINY3hrZzU5z/IpxwRxqJSJJsQ+uCVzeSEdK9jHSp3BsGR8Gzi1PD6ZQHG wFhAYVH81mL+GrStFsc63WCpr5F/J4wucRlzOER/j/4VbyEgk+IU8FVow= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Sat, 16 May 2020 20:11:56 +0800 Message-Id: <20200516121156.81344-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign7 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/hls: check target duration in the playlist X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" fix ticket: 8673 reference rfc8216 4.3.3.1 said: The EXT-X-TARGETDURATION tag is REQUIRED. in ticket 8673, the EXT-X-TARGETDURATION is incorrect, so hls should return error. Signed-off-by: Steven Liu --- libavformat/hls.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavformat/hls.c b/libavformat/hls.c index fc45719d1c..962ab78dd7 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -725,6 +725,7 @@ static int parse_playlist(HLSContext *c, const char *url, struct segment **prev_segments = NULL; int prev_n_segments = 0; int prev_start_seq_no = -1; + int have_target_duration = 0; if (is_http && !in && c->http_persistent && c->playlist_pb) { in = c->playlist_pb; @@ -809,6 +810,7 @@ static int parse_playlist(HLSContext *c, const char *url, if (ret < 0) goto fail; pls->target_duration = strtoll(ptr, NULL, 10) * AV_TIME_BASE; + have_target_duration = 1; } else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) { ret = ensure_playlist(c, &pls, url); if (ret < 0) @@ -875,6 +877,11 @@ static int parse_playlist(HLSContext *c, const char *url, } if (is_segment) { struct segment *seg; + if (!have_target_duration) { + ret = AVERROR_INVALIDDATA; + goto fail; + } + ret = ensure_playlist(c, &pls, url); if (ret < 0) goto fail;