diff mbox series

[FFmpeg-devel] avformat/hls: check target duration in the playlist

Message ID 20200516121156.81344-1-lq@chinaffmpeg.org
State New
Headers show
Series [FFmpeg-devel] avformat/hls: check target duration in the playlist
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Steven Liu May 16, 2020, 12:11 p.m. UTC
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 <lq@chinaffmpeg.org>
---
 libavformat/hls.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Carl Eugen Hoyos May 16, 2020, 12:21 p.m. UTC | #1
Am Sa., 16. Mai 2020 um 14:12 Uhr schrieb Steven Liu <lq@chinaffmpeg.org>:
>
> 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.

Can't an invalid target duration be ignored?
Or is the stream unplayable without target duration?

Carl Eugen
Steven Liu May 16, 2020, 12:44 p.m. UTC | #2
> 2020年5月16日 下午8:21,Carl Eugen Hoyos <ceffmpeg@gmail.com> 写道:
> 
> Am Sa., 16. Mai 2020 um 14:12 Uhr schrieb Steven Liu <lq@chinaffmpeg.org>:
>> 
>> 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.
> 
> Can't an invalid target duration be ignored?
> Or is the stream unplayable without target duration?
Ah, I’m wrong, it’s not EXT-X-TARGETDURATION problem.
Need continue analyse  :(
> 
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Thanks

Steven Liu
Steven Liu May 16, 2020, 12:49 p.m. UTC | #3
2020年5月16日 下午8:21,Carl Eugen Hoyos  写道: Am Sa., 16. Mai 2020 um 14:12 Uhr schrieb Steven Liu : 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. Can't an invalid target duration be ignored? Or is the stream unplayable without target duration? Ah, you are right, it’s not EXT-X-TARGETDURATION problem. Need continue analyse  :( Carl Eugen _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". Thanks Steven Liu
diff mbox series

Patch

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;