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
--- 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
-