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

Commit a0c1eb86 authored by Marco Nelissen's avatar Marco Nelissen Committed by Gerrit Code Review
Browse files

Merge "Fix potential overflows"

parents e4dbaeff 833fb390
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -305,8 +305,16 @@ status_t SampleIterator::findSampleTimeAndDuration(
        return ERROR_OUT_OF_RANGE;
    }

    while (sampleIndex >= mTTSSampleIndex + mTTSCount) {
        if (mTimeToSampleIndex == mTable->mTimeToSampleCount) {
    while (true) {
        if (mTTSSampleIndex > UINT32_MAX - mTTSCount) {
            return ERROR_OUT_OF_RANGE;
        }
        if(sampleIndex < mTTSSampleIndex + mTTSCount) {
            break;
        }
        if (mTimeToSampleIndex == mTable->mTimeToSampleCount ||
            mTTSCount > UINT32_MAX / mTTSDuration ||
            mTTSSampleTime > UINT32_MAX - (mTTSCount * mTTSDuration)) {
            return ERROR_OUT_OF_RANGE;
        }