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

Commit 20344573 authored by Wei Jia's avatar Wei Jia
Browse files

MediaCodec: check buffer size to prevent possible integer overflow for video encoder.

Bug: 25812794

Change-Id: Ib32053bc4d6a2ebe69aa4993dc32f5ab1b13ae81
parent d87e17f1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -423,6 +423,13 @@ status_t MediaCodec::configure(
        if (!format->findInt32("rotation-degrees", &mRotationDegrees)) {
            mRotationDegrees = 0;
        }

        // Prevent possible integer overflow in downstream code.
        if (mInitIsEncoder
                && (uint64_t)mVideoWidth * mVideoHeight > (uint64_t)INT32_MAX / 4) {
            ALOGE("buffer size is too big, width=%d, height=%d", mVideoWidth, mVideoHeight);
            return BAD_VALUE;
        }
    }

    msg->setMessage("format", format);