Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99e63e75 authored by Jeff Tinker's avatar Jeff Tinker Committed by Android (Google) Code Review
Browse files

Merge "Fix for security vulnerability in media server DO NOT MERGE" into lmp-dev

parents 13a8c5dd 4b219e9e
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -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);