Bug 1451681 - Handle case where crypto plain size definition didn't exist. r=cpearce
☠☠ backed out by 969deb7a468c ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 09 Apr 2018 11:39:13 +0200
changeset 412976 2198e282bdcf9cee653dfa3e4fd365444b4ef60a
parent 412975 abc6e8447dc08c7526a455b5f9b5d2e615fa6fe9
child 412977 969deb7a468c6b68fdf921a2e16a8a5302417e1e
push id33828
push userarchaeopteryx@coole-files.de
push dateThu, 12 Apr 2018 19:19:41 +0000
treeherdermozilla-central@6e22c4a726c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1451681
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1451681 - Handle case where crypto plain size definition didn't exist. r=cpearce Also ensure that the MP4 demuxer can't create such sample. MozReview-Commit-ID: JANgHNiiz2H
dom/media/mp4/Index.cpp
dom/media/platforms/agnostic/bytestreams/AnnexB.cpp
--- a/dom/media/mp4/Index.cpp
+++ b/dom/media/mp4/Index.cpp
@@ -161,17 +161,17 @@ already_AddRefed<MediaRawData> SampleIte
       writer->mCrypto.mKeyId.AppendElements(sampleInfo->mKeyId);
     }
 
     if (!reader.ReadArray(writer->mCrypto.mIV, ivSize)) {
       return nullptr;
     }
 
     auto res = reader.ReadU16();
-    if (res.isOk()) {
+    if (res.isOk() && res.unwrap() > 0) {
       uint16_t count = res.unwrap();
 
       if (reader.Remaining() < count * 6) {
         return nullptr;
       }
 
       for (size_t i = 0; i < count; i++) {
         auto res_16 = reader.ReadU16();
--- a/dom/media/platforms/agnostic/bytestreams/AnnexB.cpp
+++ b/dom/media/platforms/agnostic/bytestreams/AnnexB.cpp
@@ -69,18 +69,23 @@ AnnexB::ConvertSampleToAnnexB(mozilla::M
       return Err(NS_ERROR_OUT_OF_MEMORY);
     }
 
     // Prepending the NAL with SPS/PPS will mess up the encryption subsample
     // offsets. So we need to account for the extra bytes by increasing
     // the length of the first clear data subsample. Otherwise decryption
     // will fail.
     if (aSample->mCrypto.mValid) {
-      MOZ_ASSERT(samplewriter->mCrypto.mPlainSizes.Length() > 0);
-      samplewriter->mCrypto.mPlainSizes[0] += annexB->Length();
+      if (aSample->mCrypto.mPlainSizes.Length() == 0) {
+        samplewriter->mCrypto.mPlainSizes.AppendElement(annexB->Length());
+        samplewriter->mCrypto.mEncryptedSizes.AppendElement(
+          samplewriter->Size() - annexB->Length());
+      } else {
+        samplewriterwriter->mCrypto.mPlainSizes[0] += annexB->Length();
+      }
     }
   }
 
   return Ok();
 }
 
 already_AddRefed<mozilla::MediaByteBuffer>
 AnnexB::ConvertExtraDataToAnnexB(const mozilla::MediaByteBuffer* aExtraData)