summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJoshua J. Drake <android-open-source@qoop.org>2015-08-15 07:43:39 -0500
committerSteve Kondik <steve@cyngn.com>2016-03-22 17:14:35 -0700
commit4e35e8fa2a6c3d06a1de0add38ee8e994fcf2d42 (patch)
treec4e85baddab3e46eb942bac437ed8b1427e5167d /media
parent92742eb7af414d5818fd09fafddb6d6f79c0d9a9 (diff)
downloadframeworks_av-4e35e8fa2a6c3d06a1de0add38ee8e994fcf2d42.zip
frameworks_av-4e35e8fa2a6c3d06a1de0add38ee8e994fcf2d42.tar.gz
frameworks_av-4e35e8fa2a6c3d06a1de0add38ee8e994fcf2d42.tar.bz2
Prevent divide by zero in WAVExtractor
In the case that mNumChannels, bytesPerSample, or mSampleRate are zero, a divide by zero occurs. None of these parameters of a WAV file should ever be zero. Check that they aren't and return an error otherwise. Bug: 23285883 Change-Id: Id67b8620944405ca59572221f6f1c2b19c363e69
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/WAVExtractor.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp
index cc1d7ce..62bb416 100644
--- a/media/libstagefright/WAVExtractor.cpp
+++ b/media/libstagefright/WAVExtractor.cpp
@@ -315,9 +315,17 @@ status_t WAVExtractor::init() {
1000000LL * (mDataSize / 65 * 320) / 8000;
} else {
size_t bytesPerSample = mBitsPerSample >> 3;
+
+ if (!bytesPerSample || !mNumChannels)
+ return ERROR_MALFORMED;
+
+ size_t num_samples = mDataSize / (mNumChannels * bytesPerSample);
+
+ if (!mSampleRate)
+ return ERROR_MALFORMED;
+
durationUs =
- 1000000LL * (mDataSize / (mNumChannels * bytesPerSample))
- / mSampleRate;
+ 1000000LL * num_samples / mSampleRate;
}
mTrackMeta->setInt64(kKeyDuration, durationUs);