Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH RFC] avformat/hls: check IV size inside EXT-X-KEY
@ 2022-04-12  8:27 Zhao Zhili
  2022-04-12  8:32 ` Steven Liu
  2022-04-13 11:53 ` Anton Khirnov
  0 siblings, 2 replies; 5+ messages in thread
From: Zhao Zhili @ 2022-04-12  8:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Zhao Zhili

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@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-13 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12  8:27 [FFmpeg-devel] [PATCH RFC] avformat/hls: check IV size inside EXT-X-KEY Zhao Zhili
2022-04-12  8:32 ` Steven Liu
2022-04-13 11:53 ` Anton Khirnov
2022-04-13 12:32   ` "zhilizhao(赵志立)"
2022-04-13 13:02   ` [FFmpeg-devel] [PATCH v2] " Zhao Zhili

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git