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
This commit is contained in:
Fred Gylys-Colwell
2014-12-17 11:29:14 -08:00
parent 07478a67cb
commit 62a9cf3cbe

View File

@@ -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());