summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua J. Drake <android-open-source@qoop.org>2015-05-04 17:33:49 -0500
committerWei Jia <wjia@google.com>2015-06-03 23:20:56 +0000
commitd89104a3d5a16298742110bff1d10b43d16fef7b (patch)
treebf571d4720940a28de8aebb1fbc9bfc38467162c
parent375e349556baa6a8ea59e963c33824e9063a0eca (diff)
downloadframeworks_av-d89104a3d5a16298742110bff1d10b43d16fef7b.zip
frameworks_av-d89104a3d5a16298742110bff1d10b43d16fef7b.tar.gz
frameworks_av-d89104a3d5a16298742110bff1d10b43d16fef7b.tar.bz2
Prevent reading past the end of the buffer in 3GPP
Metadata processed within the parse3GPPMetaData function may not be NUL terminated and thus calling setCString may read out of bounds. Ensure proper NUL termination, but take care not to interfere with other special cases (ie, albm). Bug: 20923261 Change-Id: Ie93b3038b534b4c4460571a68f4d734cff7ad324 (cherry picked from commit 5cea0155cfc41f67e91343c342f44251c03fde3a)
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 080dcd1..095b9dd 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -2395,11 +2395,11 @@ status_t MPEG4Extractor::parseITunesMetaData(off64_t offset, size_t size) {
}
status_t MPEG4Extractor::parse3GPPMetaData(off64_t offset, size_t size, int depth) {
- if (size < 4) {
+ if (size < 4 || size == SIZE_MAX) {
return ERROR_MALFORMED;
}
- uint8_t *buffer = new (std::nothrow) uint8_t[size];
+ uint8_t *buffer = new (std::nothrow) uint8_t[size + 1];
if (buffer == NULL) {
return ERROR_MALFORMED;
}
@@ -2491,6 +2491,7 @@ status_t MPEG4Extractor::parse3GPPMetaData(off64_t offset, size_t size, int dept
}
if (isUTF8) {
+ buffer[size] = 0;
mFileMetaData->setCString(metadataKey, (const char *)buffer + 6);
} else {
// Convert from UTF-16 string to UTF-8 string.