Don't try to open non-existant file
Merge from Widevine repo of http://go/wvgerrit/40883 The oemcrypto dynamic adapter will try to load a keybox from the filesystem if oemcrypto reports it doesn't have one. Previously, it would check the size of the file, and then open the file before responding to errors. Opening a non-existant file would result in a segfault. With this CL, we do not try to open the file if the size is not positive. Test: unit tests Bug: 72129404 Change-Id: I243b5d49837455c0ce07802e32e4d7e809286cfd
This commit is contained in:
@@ -714,8 +714,16 @@ class Adapter {
|
||||
return false;
|
||||
}
|
||||
ssize_t size = file_system.FileSize(filename);
|
||||
if (size <= 0) {
|
||||
LOGW("Could not find %s. Falling Back to L3.", filename.c_str());
|
||||
level1_.Terminate();
|
||||
metrics->OemCryptoDynamicAdapterMetrics::SetInitializationMode(
|
||||
wvcdm::metrics::
|
||||
OEMCrypto_INITIALIZED_USING_L3_COULD_NOT_OPEN_FACTORY_KEYBOX);
|
||||
return false;
|
||||
}
|
||||
wvcdm::File* file = file_system.Open(filename, file_system.kReadOnly);
|
||||
if (size <= 0 || !file) {
|
||||
if (!file) {
|
||||
LOGW("Could not open %s. Falling Back to L3.", filename.c_str());
|
||||
level1_.Terminate();
|
||||
metrics->OemCryptoDynamicAdapterMetrics::SetInitializationMode(
|
||||
|
||||
Reference in New Issue
Block a user