Bug 1289968 - [Part2] Provide max length limitation for KeyIds and Webm Initdata, then correct cooresponding web-platform-tests meta file. r=gerald
authorKilik Kuo <kikuo@mozilla.com>
Sat, 17 Sep 2016 03:24:49 +0800
changeset 314614 3c1e96d92dcf6c4f87762cd6a695cc8ab4a13715
parent 314613 3c959ee59f94f252710cfe01691369933d10dab8
child 314615 150109898e5fe28f6f1e3b2587fc357329f5195f
push id30732
push usercbook@mozilla.com
push dateWed, 21 Sep 2016 10:04:03 +0000
treeherdermozilla-central@560b2c805bf7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1289968
milestone52.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 1289968 - [Part2] Provide max length limitation for KeyIds and Webm Initdata, then correct cooresponding web-platform-tests meta file. r=gerald MozReview-Commit-ID: DbaF1wZXwav
media/gmp-clearkey/0.1/ClearKeySession.cpp
media/gmp-clearkey/0.1/ClearKeyUtils.cpp
media/gmp-clearkey/0.1/ClearKeyUtils.h
testing/web-platform/meta/encrypted-media/Google/encrypted-media-keystatuses-multiple-sessions.html.ini
testing/web-platform/meta/encrypted-media/Google/encrypted-media-keystatuses-multiple-updates.html.ini
testing/web-platform/meta/encrypted-media/Google/encrypted-media-keystatuses.html.ini
testing/web-platform/meta/encrypted-media/Google/encrypted-media-syntax.html.ini
--- a/media/gmp-clearkey/0.1/ClearKeySession.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeySession.cpp
@@ -65,17 +65,17 @@ ClearKeySession::Init(uint32_t aCreateSe
   } else if (aInitDataType == "keyids") {
     std::string sessionType;
     ClearKeyUtils::ParseKeyIdsInitData(aInitData, aInitDataSize, mKeyIds, sessionType);
     if (sessionType != ClearKeyUtils::SessionTypeToString(mSessionType)) {
       const char message[] = "Session type specified in keyids init data doesn't match session type.";
       mCallback->RejectPromise(aPromiseId, kGMPInvalidAccessError, message, strlen(message));
       return;
     }
-  } else if (aInitDataType == "webm") {
+  } else if (aInitDataType == "webm" && aInitDataSize <= kMaxWebmInitDataSize) {
     // "webm" initData format is simply the raw bytes of the keyId.
     vector<uint8_t> keyId;
     keyId.assign(aInitData, aInitData+aInitDataSize);
     mKeyIds.push_back(keyId);
   }
 
   if (!mKeyIds.size()) {
     const char message[] = "Couldn't parse init data";
--- a/media/gmp-clearkey/0.1/ClearKeyUtils.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyUtils.cpp
@@ -440,17 +440,17 @@ ParseKeyIds(ParserContext& aCtx, vector<
   EXPECT_SYMBOL(aCtx, '[');
 
   while (true) {
     string label;
     vector<uint8_t> keyId;
     if (!GetNextLabel(aCtx, label) || !DecodeBase64(label, keyId)) {
       return false;
     }
-    if (!keyId.empty()) {
+    if (!keyId.empty() && keyId.size() <= kMaxKeyIdsLength) {
       aOutKeyIds.push_back(keyId);
     }
 
     uint8_t sym = PeekSymbol(aCtx);
     if (!sym || sym == ']') {
       break;
     }
 
--- a/media/gmp-clearkey/0.1/ClearKeyUtils.h
+++ b/media/gmp-clearkey/0.1/ClearKeyUtils.h
@@ -35,16 +35,20 @@ void CK_Log(const char* aFmt, ...);
 #endif
 
 struct GMPPlatformAPI;
 extern GMPPlatformAPI* GetPlatform();
 
 typedef std::vector<uint8_t> KeyId;
 typedef std::vector<uint8_t> Key;
 
+// Provide limitation for KeyIds length and webm initData size.
+static const uint32_t kMaxWebmInitDataSize = 65536;
+static const uint32_t kMaxKeyIdsLength = 512;
+
 struct KeyIdPair
 {
   KeyId mKeyId;
   Key mKey;
 };
 
 class ClearKeyUtils
 {
deleted file mode 100644
--- a/testing/web-platform/meta/encrypted-media/Google/encrypted-media-keystatuses-multiple-sessions.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[encrypted-media-keystatuses-multiple-sessions.html]
-  type: testharness
-  [Verify MediaKeySession.keyStatuses with multiple sessions.]
-    expected: TIMEOUT
-
deleted file mode 100644
--- a/testing/web-platform/meta/encrypted-media/Google/encrypted-media-keystatuses-multiple-updates.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[encrypted-media-keystatuses-multiple-updates.html]
-  type: testharness
-  [Verify MediaKeySession.keyStatuses with multiple updates.]
-    expected: TIMEOUT
-
--- a/testing/web-platform/meta/encrypted-media/Google/encrypted-media-keystatuses.html.ini
+++ b/testing/web-platform/meta/encrypted-media/Google/encrypted-media-keystatuses.html.ini
@@ -1,5 +1,4 @@
 [encrypted-media-keystatuses.html]
   type: testharness
   [Verify MediaKeySession.keyStatuses.]
-    expected: TIMEOUT
-
+    expected: FAIL
--- a/testing/web-platform/meta/encrypted-media/Google/encrypted-media-syntax.html.ini
+++ b/testing/web-platform/meta/encrypted-media/Google/encrypted-media-syntax.html.ini
@@ -7,20 +7,16 @@
     expected: TIMEOUT
 
   [Test MediaKeys load() exceptions.]
     expected: TIMEOUT
 
   [Test MediaKeySession update() exceptions.]
     expected: TIMEOUT
 
-  [Test MediaKeySession update().]
-    expected: TIMEOUT
-
   [Test MediaKeySession close().]
     expected: TIMEOUT
 
   [Test MediaKeys setServerCertificate() exceptions.]
     expected: TIMEOUT
 
   [Test MediaKeys setServerCertificate().]
     expected: TIMEOUT
-