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

Zhao Zhili quinkblack at foxmail.com
Wed Apr 13 16:02:58 EEST 2022


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 --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));
-- 
2.31.1



More information about the ffmpeg-devel mailing list