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

Commit e34eae2d authored by Dan Austin's avatar Dan Austin
Browse files

Refactor setPlaybackRate to avoid benign unsigned integer overflow.

There is a check that results in a benign unsigned integer overflow.
This has been refactored to avoid the unsigned integer overflow.

Bug: 25327431
Change-Id: Ib112a7cd585c680f13e4bee3d7e9f45da7d66f1d
parent 58fdf7cc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -822,13 +822,13 @@ status_t AudioTrack::setPlaybackRate(const AudioPlaybackRate &playbackRate)
    }

    // Check resampler ratios are within bounds
    if (effectiveRate > mSampleRate * AUDIO_RESAMPLER_DOWN_RATIO_MAX) {
    if ((uint64_t)effectiveRate > (uint64_t)mSampleRate * (uint64_t)AUDIO_RESAMPLER_DOWN_RATIO_MAX) {
        ALOGV("setPlaybackRate(%f, %f) failed. Resample rate exceeds max accepted value",
                playbackRate.mSpeed, playbackRate.mPitch);
        return BAD_VALUE;
    }

    if (effectiveRate * AUDIO_RESAMPLER_UP_RATIO_MAX < mSampleRate) {
    if ((uint64_t)effectiveRate * (uint64_t)AUDIO_RESAMPLER_UP_RATIO_MAX < (uint64_t)mSampleRate) {
        ALOGV("setPlaybackRate(%f, %f) failed. Resample rate below min accepted value",
                        playbackRate.mSpeed, playbackRate.mPitch);
        return BAD_VALUE;