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

Commit fbf2cecd authored by Marco Nelissen's avatar Marco Nelissen Committed by Michael Bestas
Browse files

Check NAL size before use

Bug: 24441553
Bug: 24445122
Change-Id: Ib7f025769adbafd5a2cb64fae5562a0a565945c2
(cherry picked from commit 5d101298)
parent 933b0930
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -3443,7 +3443,10 @@ status_t MPEG4Source::read(
            (const uint8_t *)mBuffer->data() + mBuffer->range_offset();

        size_t nal_size = parseNALSize(src);
        if (mBuffer->range_length() < mNALLengthSize + nal_size) {
        if (mNALLengthSize > SIZE_MAX - nal_size) {
            ALOGE("b/24441553, b/24445122");
        }
        if (mBuffer->range_length() - mNALLengthSize < nal_size) {
            ALOGE("incomplete NAL unit.");

            mBuffer->release();
@@ -3708,7 +3711,11 @@ status_t MPEG4Source::fragmentedRead(
            (const uint8_t *)mBuffer->data() + mBuffer->range_offset();

        size_t nal_size = parseNALSize(src);
        if (mBuffer->range_length() < mNALLengthSize + nal_size) {
        if (mNALLengthSize > SIZE_MAX - nal_size) {
            ALOGE("b/24441553, b/24445122");
        }

        if (mBuffer->range_length() - mNALLengthSize < nal_size) {
            ALOGE("incomplete NAL unit.");

            mBuffer->release();