summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-09-16 15:20:33 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-09-16 15:20:33 -0700
commita7516e90d01a22d17a470695eefa905e0ff066cc (patch)
tree13cdceabe3186b3a93319cc317878f4e871c41c5 /media
parent549629d36690ac09498d0a9b2aac4ae4ceb7eead (diff)
parent4f5bb1e6998d068a44fd562f47820fe5d6ef5067 (diff)
downloadframeworks_base-a7516e90d01a22d17a470695eefa905e0ff066cc.zip
frameworks_base-a7516e90d01a22d17a470695eefa905e0ff066cc.tar.gz
frameworks_base-a7516e90d01a22d17a470695eefa905e0ff066cc.tar.bz2
Merge "Make sure the .wav extractor does not read data outside the bounds of the 'data' box." into gingerbread
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/WAVExtractor.cpp13
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();