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

Commit 0f944633 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Check for crypto size overflow"

parents 46f11bd3 62e83c95
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -239,8 +239,14 @@ NuPlayerDrm::CryptoInfo *NuPlayerDrm::makeCryptoInfo(
        size_t *encryptedbytes)
{
    // size needed to store all the crypto data
    size_t cryptosize = sizeof(CryptoInfo) +
                        sizeof(CryptoPlugin::SubSample) * numSubSamples;
    size_t cryptosize;
    // sizeof(CryptoInfo) + sizeof(CryptoPlugin::SubSample) * numSubSamples;
    if (__builtin_mul_overflow(sizeof(CryptoPlugin::SubSample), numSubSamples, &cryptosize) ||
            __builtin_add_overflow(cryptosize, sizeof(CryptoInfo), &cryptosize)) {
        ALOGE("crypto size overflow");
        return NULL;
    }

    CryptoInfo *ret = (CryptoInfo*) malloc(cryptosize);
    if (ret == NULL) {
        ALOGE("couldn't allocate %zu bytes", cryptosize);