diff options
author | Jeff Tinker <jtinker@google.com> | 2015-08-26 20:22:39 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2015-09-28 17:08:15 -0700 |
commit | 64ec616534d5bc44e563a92095b375d3c180635e (patch) | |
tree | 81845b17f9ce4fc28bfdbc231eb890644f7f8be0 /media/libmedia/ICrypto.cpp | |
parent | 66296c4e99da5f2dd0a3dbf048be0d6ffc49a559 (diff) | |
download | frameworks_av-64ec616534d5bc44e563a92095b375d3c180635e.zip frameworks_av-64ec616534d5bc44e563a92095b375d3c180635e.tar.gz frameworks_av-64ec616534d5bc44e563a92095b375d3c180635e.tar.bz2 |
Fix for security vulnerability in media server
bug: 23540426
Change-Id: Ifb12ac3350410a49ba7d81d1bde12822c3008cd5
Diffstat (limited to 'media/libmedia/ICrypto.cpp')
-rw-r--r-- | media/libmedia/ICrypto.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/media/libmedia/ICrypto.cpp b/media/libmedia/ICrypto.cpp index 947294f..9703b0d 100644 --- a/media/libmedia/ICrypto.cpp +++ b/media/libmedia/ICrypto.cpp @@ -303,7 +303,25 @@ status_t BnCrypto::onTransact( AString errorDetailMsg; ssize_t result; - if (offset + totalSize > sharedBuffer->size()) { + 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 if (offset + totalSize > sharedBuffer->size()) { result = -EINVAL; } else { result = decrypt( |