Bug 1409670 - Skip decrypting request when receiving an unencrypted sample in Clearkey implementation. r=cpearce
authorJames Cheng <jacheng@mozilla.com>
Thu, 19 Oct 2017 16:45:21 +0800
changeset 683862 58190ad9f36d303669e45fd91b6793ae1dea9a01
parent 683861 6a815fb0b667075041404ebd0b1ee7b87f46e3a2
child 683863 d1e995c8640a191cd127e87273ec96cb2fabffa9
child 683959 23b3ec9f9b2a19714f80f829bd89b8a587f2155a
push id85474
push userbmo:emilio@crisal.io
push dateFri, 20 Oct 2017 10:02:12 +0000
reviewerscpearce
bugs1409670
milestone58.0a1
Bug 1409670 - Skip decrypting request when receiving an unencrypted sample in Clearkey implementation. r=cpearce MozReview-Commit-ID: 5XIUeFc3PSD
media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
--- a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
@@ -634,19 +634,24 @@ ClearKeySessionManager::Decrypt(const In
 
   Buffer* buffer = mHost->Allocate(aBuffer.data_size);
   assert(buffer != nullptr);
   assert(buffer->Data() != nullptr);
   assert(buffer->Capacity() >= aBuffer.data_size);
 
   memcpy(buffer->Data(), aBuffer.data, aBuffer.data_size);
 
-  Status status = mDecryptionManager->Decrypt(buffer->Data(),
-                                              buffer->Size(),
-                                              CryptoMetaData(&aBuffer));
+  Status status = Status::kSuccess;
+  // According to the comment `If |iv_size| = 0, the data is unencrypted.`
+  // Use iv_size to determine if the sample is encrypted.
+  if (aBuffer.iv_size != 0) {
+    status = mDecryptionManager->Decrypt(buffer->Data(),
+                                         buffer->Size(),
+                                         CryptoMetaData(&aBuffer));
+  }
 
   aDecryptedBlock->SetDecryptedBuffer(buffer);
   aDecryptedBlock->SetTimestamp(aBuffer.timestamp);
 
   return status;
 }
 
 void