From 18e6aba25364b988ac52413949f62eef03d6c648 Mon Sep 17 00:00:00 2001
From: Jacob Trimble <modmaker@google.com>
Date: Tue, 14 Aug 2018 10:18:55 -0700
Subject: [PATCH] avformat/mov: Allow saio/saiz in clear content.
If there is a saio/saiz in clear content, we shouldn't create the
encryption index if we don't already have one. Otherwise it will
confuse the cenc_filter.
The changed method is also used for senc atoms, but they should not
appear in clear content.
Found by Chromium's ClusterFuzz: https://crbug.com/873432
Signed-off-by: Jacob Trimble <modmaker@google.com>
---
libavformat/mov.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -5847,6 +5847,9 @@ static int get_current_encryption_info(MOVContext *c, MOVEncryptionIndex **encry
*sc = st->priv_data;
if (!frag_stream_info->encryption_index) {
+ // If this stream isn't encrypted, don't create the index.
+ if (!(*sc)->cenc.default_encrypted_sample)
+ return 0;
frag_stream_info->encryption_index = av_mallocz(sizeof(*frag_stream_info->encryption_index));
if (!frag_stream_info->encryption_index)
return AVERROR(ENOMEM);
@@ -5862,6 +5865,9 @@ static int get_current_encryption_info(MOVContext *c, MOVEncryptionIndex **encry
*sc = st->priv_data;
if (!(*sc)->cenc.encryption_index) {
+ // If this stream isn't encrypted, don't create the index.
+ if (!(*sc)->cenc.default_encrypted_sample)
+ return 0;
(*sc)->cenc.encryption_index = av_mallocz(sizeof(*frag_stream_info->encryption_index));
if (!(*sc)->cenc.encryption_index)
return AVERROR(ENOMEM);
--
2.18.0.865.gffc8e1a3cd6-goog