diff mbox series

[FFmpeg-devel,v2] avformat/hls: check IV size inside EXT-X-KEY

Message ID tencent_C2DBCF975561A76738E8160E4D6EA0194D07@qq.com
State New
Headers show
Series [FFmpeg-devel,v2] avformat/hls: check IV size inside EXT-X-KEY | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Zhao Zhili April 13, 2022, 1:02 p.m. UTC
Before the patch, an implicit padding on the right is applied for
incomplete IV in manifest. No padding is allowed for IV inside
EXT-X-KEY.
---
 libavformat/hls.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 83ff4cc607..312294f0c7 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -810,7 +810,12 @@  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 != 16) {
+                    av_log(c->ctx, AV_LOG_ERROR, "Incomplete IV '%s'\n", info.iv);
+                    ret = AVERROR_INVALIDDATA;
+                    goto fail;
+                }
                 has_iv = 1;
             }
             av_strlcpy(key, info.uri, sizeof(key));