From 1514ae0dfb1f2e5fdfea2ef022f727f76d43e68f Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 17 Dec 2014 11:29:14 -0800 Subject: [PATCH] Terminate Level 1 OEMCrypto on Initialization Error Cherry pick of the widevine change https://widevine-internal-review.googlesource.com/#/c/12082/ If the level 1 oemcrypto library loads and initializes, but has the wrong version or does not have a valid keybox, then the level 3 fallback is used. However, in those cases, the level 1 was not terminated properly. This caused a resource leak on some platforms. With this CL, in OEMCrypto_Initialize, the level 1 library Terminate is called if its Initialize was called and the level 1 library will not be used. bug: 18755226 Change-Id: I56e7d3349eeebd94f3fa8c4a1f4b21781cc7428b (cherry picked from commit 62a9cf3cbea34f2d04c50809703d31efd78514d9) --- libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp index 730ce0a6..6361ad23 100644 --- a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp +++ b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp @@ -280,6 +280,7 @@ class Adapter { if (level1_.version < minimum_version) { LOGW("liboemcrypto.so is version %d, not %d. Falling Back to L3.", level1_.version, minimum_version); + level1_.Terminate(); return false; } if( level1_.version == 8 ) { @@ -303,11 +304,13 @@ class Adapter { std::string filename; if (!wvcdm::Properties::GetFactoryKeyboxPath(&filename)) { LOGW("Bad Level 1 Keybox. Falling Back to L3."); + level1_.Terminate(); return false; } ssize_t size = file.FileSize(filename); if (size <= 0 || !file.Open(filename, file.kBinary | file.kReadOnly)) { LOGW("Could not open %s. Falling Back to L3.", filename.c_str()); + level1_.Terminate(); return false; } uint8_t keybox[size]; @@ -315,6 +318,7 @@ class Adapter { if (level1_.InstallKeybox(keybox, size) != OEMCrypto_SUCCESS) { LOGE("Could NOT install keybox from %s. Falling Back to L3.", filename.c_str()); + level1_.Terminate(); return false; } LOGI("Installed keybox from %s", filename.c_str());