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

Commit 92aa28ad authored by Andreas Huber's avatar Andreas Huber Committed by Android Git Automerger
Browse files

am a7516e90: Merge "Make sure the .wav extractor does not read data outside...

am a7516e90: Merge "Make sure the .wav extractor does not read data outside the bounds of the \'data\' box." into gingerbread

Merge commit 'a7516e90' into gingerbread-plus-aosp

* commit 'a7516e90':
  Make sure the .wav extractor does not read data outside the bounds of the 'data' box.
parents 23c6ad7a a7516e90
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -331,9 +331,20 @@ status_t WAVSource::read(
        return err;
    }

    size_t maxBytesToRead =
        mBitsPerSample == 8 ? kMaxFrameSize / 2 : kMaxFrameSize;

    size_t maxBytesAvailable =
        (mCurrentPos - mOffset >= (off_t)mSize)
            ? 0 : mSize - (mCurrentPos - mOffset);

    if (maxBytesToRead > maxBytesAvailable) {
        maxBytesToRead = maxBytesAvailable;
    }

    ssize_t n = mDataSource->readAt(
            mCurrentPos, buffer->data(),
            mBitsPerSample == 8 ? kMaxFrameSize / 2 : kMaxFrameSize);
            maxBytesToRead);

    if (n <= 0) {
        buffer->release();