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

Commit 9247e105 authored by Edwin Wong's avatar Edwin Wong
Browse files

Check opaque size in CREATE_PLUGIN.

Check opaque size to be not greater than an abitrary 100K
and verify malloc succeeded.

Test: Play Movies & TV

Test: Netflix

Test: ANDROID_BUILD_TOP= ./android-gts/tools/gts-tradefed run gts
 -m GtsMediaTestCases --test
com.google.android.media.gts.WidevineH264PlaybackTests#testL1With480P60

Test: Forcing opaque size to exceed limit and malloc to report failure;
  both resulted in Netflix reporting an error and failing to play.
  This is the expected result.

bug: 30202440
Change-Id: I9fdaf208471f2781ffbd656358b1bf1ef5b28ee8
parent 1ac2e2bd
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -235,17 +235,21 @@ status_t BnCrypto::onTransact(
            size_t opaqueSize = data.readInt32();
            void *opaqueData = NULL;

            if (opaqueSize > 0) {
            const size_t kMaxOpaqueSize = 100 * 1024;
            if (opaqueSize > kMaxOpaqueSize) {
                return BAD_VALUE;
            }

            opaqueData = malloc(opaqueSize);
                data.read(opaqueData, opaqueSize);
            if (NULL == opaqueData) {
                return NO_MEMORY;
            }

            data.read(opaqueData, opaqueSize);
            reply->writeInt32(createPlugin(uuid, opaqueData, opaqueSize));

            if (opaqueData != NULL) {
            free(opaqueData);
            opaqueData = NULL;
            }

            return OK;
        }