summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
authorJeff Tinker <jtinker@google.com>2015-09-14 11:55:43 -0700
committerJeff Tinker <jtinker@google.com>2015-09-14 18:59:06 +0000
commit4b219e9e5ab237eec9931497cf10db4d78982d84 (patch)
tree062e4c9ffb383786c57f29fba05fea148cd0cf9b /media/libmedia
parentf3eb82683a80341f5ac23057aab733a57963cab2 (diff)
downloadframeworks_av-4b219e9e5ab237eec9931497cf10db4d78982d84.zip
frameworks_av-4b219e9e5ab237eec9931497cf10db4d78982d84.tar.gz
frameworks_av-4b219e9e5ab237eec9931497cf10db4d78982d84.tar.bz2
Fix for security vulnerability in media server DO NOT MERGE
bug: 23540426 Change-Id: I7ca419e4008967a0387649e5293ac9d4be71d3c4
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/ICrypto.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/media/libmedia/ICrypto.cpp b/media/libmedia/ICrypto.cpp
index 7bd120e..0d68ee7 100644
--- a/media/libmedia/ICrypto.cpp
+++ b/media/libmedia/ICrypto.cpp
@@ -255,7 +255,28 @@ status_t BnCrypto::onTransact(
}
AString errorDetailMsg;
- ssize_t result = decrypt(
+ ssize_t result;
+
+ size_t sumSubsampleSizes = 0;
+ bool overflow = false;
+ for (int32_t i = 0; i < numSubSamples; ++i) {
+ CryptoPlugin::SubSample &ss = subSamples[i];
+ if (sumSubsampleSizes <= SIZE_MAX - ss.mNumBytesOfEncryptedData) {
+ sumSubsampleSizes += ss.mNumBytesOfEncryptedData;
+ } else {
+ overflow = true;
+ }
+ if (sumSubsampleSizes <= SIZE_MAX - ss.mNumBytesOfClearData) {
+ sumSubsampleSizes += ss.mNumBytesOfClearData;
+ } else {
+ overflow = true;
+ }
+ }
+
+ if (overflow || sumSubsampleSizes != totalSize) {
+ result = -EINVAL;
+ } else {
+ result = decrypt(
secure,
key,
iv,
@@ -264,6 +285,7 @@ status_t BnCrypto::onTransact(
subSamples, numSubSamples,
secure ? secureBufferId : dstPtr,
&errorDetailMsg);
+ }
reply->writeInt32(result);