Bug 1308424-[Part1] Verify the license response size while updating session. r=cpearce

MozReview-Commit-ID: IXZLWnbYTn9

--HG--
extra : rebase_source : fbf015e56443320c55960121e4d59379d9ffabcd
This commit is contained in:
Kilik Kuo 2016-10-07 18:16:30 +08:00
Родитель 7ca77325f6
Коммит 26bd0bc8ef
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -217,6 +217,13 @@ ClearKeySessionManager::UpdateSession(uint32_t aPromiseId,
}
ClearKeySession* session = itr->second;
// Verify the size of session response.
if (aResponseSize >= kMaxSessionResponseLength) {
CK_LOGW("Session response size is not within a reasonable size.");
mCallback->RejectPromise(aPromiseId, kGMPInvalidAccessError, nullptr, 0);
return;
}
// Parse the response for any (key ID, key) pairs.
vector<KeyIdPair> keyPairs;
if (!ClearKeyUtils::ParseJWK(aResponse, aResponseSize, keyPairs, session->Type())) {

Просмотреть файл

@ -40,6 +40,10 @@ extern GMPPlatformAPI* GetPlatform();
typedef std::vector<uint8_t> KeyId;
typedef std::vector<uint8_t> Key;
// The session response size should be within a reasonable limit.
// The size 64 KB is referenced from web-platform-test.
static const uint32_t kMaxSessionResponseLength = 65536;
// Provide limitation for KeyIds length and webm initData size.
static const uint32_t kMaxWebmInitDataSize = 65536;
static const uint32_t kMaxKeyIdsLength = 512;