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

Commit a955a9de authored by Robert Shih's avatar Robert Shih Committed by Vasyl Gello
Browse files

BnCrypto: fix use-before-init in CREATE_PLUGIN

Bug: 144767096
Test: poc_ICrypto_283
Merged-In: Id67dc9e793ee886e4cc49370d800c7f3580df313
Merged-In: I81ff7cde5e1693f05c90380e879f74d0c4bce5f1
Change-Id: If268553440b8a0cbbe011b5396974fd864a7d083
(cherry picked from commit 4bbfb6d8)
parent e5a890c4
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -238,15 +238,23 @@ status_t BnCrypto::onTransact(
        {
            CHECK_INTERFACE(ICrypto, data, reply);

            uint8_t uuid[16];
            data.read(uuid, sizeof(uuid));
            uint8_t uuid[16] = {0};
            if (data.read(uuid, sizeof(uuid)) != NO_ERROR) {
                android_errorWriteLog(0x534e4554, "144767096");
                reply->writeInt32(BAD_VALUE);
                return OK;
            }

            size_t opaqueSize = data.readInt32();
            void *opaqueData = NULL;

            if (opaqueSize > 0) {
                opaqueData = malloc(opaqueSize);
                data.read(opaqueData, opaqueSize);
                if (data.read(opaqueData, opaqueSize) != NO_ERROR) {
                    android_errorWriteLog(0x534e4554, "144767096");
                    reply->writeInt32(BAD_VALUE);
                    return OK;
                }
            }

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