[WVDRM] Fix effectively-unlimited memory usage

Change 14f0d to read the maximum buffer size from a device property did not
work correctly on Mako and Prime devices, as they did not have the property
set, and the code to fall back to a default value was not working. An empty
string would be read instead of the default value, resulting in a maximum of
zero. Because Widevine Media Kit would then subtract a few megabytes from this,
it would underflow, giving a maximum buffer size of several gigabytes. This
would lead to the download code trying to pre-buffer the entire, many-gigabyte
movie. As the media server's memory usage grew and grew, other programs would
become starved for memory, leading to most other processes on the phone being
forced to close. Eventually, the playback app, the media server, or some other
crucial piece of functionality would be starved, resulting in a crash.

The fix is to fix how we get the default, so that when the property is not
available, we get a sensible result. We check the return value of property_get.
If it is greater than zero, the property was read successfully, and we parse
the answer. If it is equal to (or less than) zero, we fall back to the default
value.

Bug: 7222769
Change-Id: Ie6186a0533036ab8fa45b1e467611d55f7c345ac
This commit is contained in:
John "Juce" Bruce
2012-10-03 17:51:21 -07:00
parent 71422e7a2a
commit 2ce9ab8e67

View File

@@ -640,10 +640,12 @@ void WVMExtractorImpl::setUID(uid_t uid)
size_t WVMExtractorImpl::getStreamCacheSize() const
{
char value[PROPERTY_VALUE_MAX];
snprintf(value, sizeof(value), "%d", kDefaultStreamCacheSize);
property_get("ro.com.widevine.cachesize", value, NULL);
return atol(value);
if (property_get("ro.com.widevine.cachesize", value, NULL) > 0) {
return atol(value);
} else {
return kDefaultStreamCacheSize;
}
}
status_t WVMExtractorImpl::getError() {