[FFmpeg-devel] [PATCH RFC] avformat/hls: check IV size inside EXT-X-KEY
Steven Liu
lingjiujianke at gmail.com
Tue Apr 12 11:32:21 EEST 2022
Zhao Zhili <quinkblack at foxmail.com> 于2022年4月12日周二 16:28写道:
>
> IV should always be 128 bits. If the IV attribute was truncated
> inside EXT-X-KEY, padding on the left which is the same as when
> using sequence number as IV.
> ---
> I'm not sure which method is better: do padding or just return
> AVERROR_INVALIDDATA?
>
> libavformat/hls.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 83ff4cc607..a7b632c20e 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -810,7 +810,13 @@ static int parse_playlist(HLSContext *c, const char *url,
> if (!strcmp(info.method, "SAMPLE-AES"))
> key_type = KEY_SAMPLE_AES;
> if (!av_strncasecmp(info.iv, "0x", 2)) {
> - ff_hex_to_data(iv, info.iv + 2);
> + int n = ff_hex_to_data(iv, info.iv + 2);
> + if (n < sizeof(iv)) {
> + av_log(c->ctx, AV_LOG_WARNING,
> + "Incomplete IV %s, padding on the left\n", info.iv);
> + memmove(iv + sizeof(iv) - n, iv, n);
> + memset(iv, 0, sizeof(iv) - n);
> + }
> has_iv = 1;
> }
> av_strlcpy(key, info.uri, sizeof(key));
> --
> 2.31.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
LGTM
Thanks
Steven
More information about the ffmpeg-devel
mailing list