diff options
author | Andreas Huber <andih@google.com> | 2010-09-16 17:29:30 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-09-16 17:29:30 -0700 |
commit | 302a965f4bf5d179ccc68b7d853e2806941de020 (patch) | |
tree | 2f58167481686655810d4d8310eec0719cbacf79 | |
parent | d6c23e7e09b97350a9e7a54dca91a9c7c48cb9a5 (diff) | |
parent | 0e38944cc890cc3c68077c8e29d63e6107c9d184 (diff) | |
download | frameworks_av-302a965f4bf5d179ccc68b7d853e2806941de020.zip frameworks_av-302a965f4bf5d179ccc68b7d853e2806941de020.tar.gz frameworks_av-302a965f4bf5d179ccc68b7d853e2806941de020.tar.bz2 |
am 92aa28ad: am a7516e90: Merge "Make sure the .wav extractor does not read data outside the bounds of the \'data\' box." into gingerbread
Merge commit '92aa28addd5dbe576b2c1b66cbc00c561402f2b9'
* commit '92aa28addd5dbe576b2c1b66cbc00c561402f2b9':
Make sure the .wav extractor does not read data outside the bounds of the 'data' box.
-rw-r--r-- | media/libstagefright/WAVExtractor.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp index 57c1075..aff06bc 100644 --- a/media/libstagefright/WAVExtractor.cpp +++ b/media/libstagefright/WAVExtractor.cpp @@ -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(); |