From 59da4188833cf281043a08deb788e59cca23b153 Mon Sep 17 00:00:00 2001 From: Edwin Wong Date: Thu, 6 Nov 2014 17:07:48 -0800 Subject: [PATCH] Remove corrupted license file from storage. (This is a port of http://go/wvgerrit/11614 from the Widevine repo.) CDM does not recover if a license file has invalid size or the hash is incorrect. Remove the corrupted license file in such cases. bug: 18002606 Change-Id: I46dec853ce6b2e7c7430297d50df5d30488cde3b --- libwvdrmengine/cdm/core/src/device_files.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libwvdrmengine/cdm/core/src/device_files.cpp b/libwvdrmengine/cdm/core/src/device_files.cpp index 92869026..0bee6012 100644 --- a/libwvdrmengine/cdm/core/src/device_files.cpp +++ b/libwvdrmengine/cdm/core/src/device_files.cpp @@ -603,6 +603,9 @@ bool DeviceFiles::RetrieveFile(const char* name, std::string* serialized_file) { ssize_t bytes = file_->FileSize(path); if (bytes <= 0) { LOGW("DeviceFiles::RetrieveFile: File size invalid: %s", path.c_str()); + // Remove the corrupted file so the caller will not get the same error + // when trying to access the file repeatedly, causing the system to stall. + file_->Remove(path); return false; } @@ -637,6 +640,9 @@ bool DeviceFiles::RetrieveFile(const char* name, std::string* serialized_file) { if (hash.compare(hash_file.hash())) { LOGW("DeviceFiles::RetrieveFile: Hash mismatch"); + // Remove the corrupted file so the caller will not get the same error + // when trying to access the file repeatedly, causing the system to stall. + file_->Remove(path); return false; }