summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MPEG4Extractor.cpp
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2015-06-04 11:01:15 -0700
committerAbhishek Arya <aarya@google.com>2015-08-21 21:34:14 -0700
commitdedaca6f04ac9f95fabe3b64d44cd1a2050f079e (patch)
treeaac33f0ddaaae3cf66043bb3e801fc53a635afbe /media/libstagefright/MPEG4Extractor.cpp
parent3b42241aab5855964d1bd60268ae21c2d9cc6065 (diff)
downloadframeworks_av-dedaca6f04ac9f95fabe3b64d44cd1a2050f079e.zip
frameworks_av-dedaca6f04ac9f95fabe3b64d44cd1a2050f079e.tar.gz
frameworks_av-dedaca6f04ac9f95fabe3b64d44cd1a2050f079e.tar.bz2
Limit allocations to avoid out-of-memory
Corrupt files could cause very large allocations, limit them to something more reasonable. Bug: 17769851 Change-Id: Ib0f722fd6fddff873bd7a547aac456e608c34c84
Diffstat (limited to 'media/libstagefright/MPEG4Extractor.cpp')
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 8ca45ad..92065d1 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -2504,16 +2504,24 @@ status_t MPEG4Source::start(MetaData *params) {
mWantsNALFragments = false;
}
+ int32_t tmp;
+ CHECK(mFormat->findInt32(kKeyMaxInputSize, &tmp));
+ size_t max_size = tmp;
+
+ // A somewhat arbitrary limit that should be sufficient for 8k video frames
+ // If you see the message below for a valid input stream: increase the limit
+ if (max_size > 64 * 1024 * 1024) {
+ ALOGE("bogus max input size: %zu", max_size);
+ return ERROR_MALFORMED;
+ }
mGroup = new MediaBufferGroup;
-
- int32_t max_size;
- CHECK(mFormat->findInt32(kKeyMaxInputSize, &max_size));
-
mGroup->add_buffer(new MediaBuffer(max_size));
mSrcBuffer = new (std::nothrow) uint8_t[max_size];
if (mSrcBuffer == NULL) {
// file probably specified a bad max size
+ delete mGroup;
+ mGroup = NULL;
return ERROR_MALFORMED;
}