Skip to content

Commit 00b3442

Browse files
jduckandi34
authored andcommitted
Prevent integer overflow when processing covr MPEG4 atoms
If the 'chunk_data_size' value is SIZE_MAX, an integer overflow will occur and cause an undersized buffer to be allocated. The following processing then overfills the resulting memory and creates a potentially exploitable condition. Ensure that integer overflow does not occur. Bug: 20923261 Change-Id: I75cce323aec04a612e5a230ecd7c2077ce06035f
1 parent c88d6b7 commit 00b3442

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

media/libstagefright/MPEG4Extractor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,10 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
17521752
if (mFileMetaData != NULL) {
17531753
ALOGV("chunk_data_size = %lld and data_offset = %lld",
17541754
chunk_data_size, data_offset);
1755+
1756+
if (chunk_data_size >= SIZE_MAX - 1) {
1757+
return ERROR_MALFORMED;
1758+
}
17551759
sp<ABuffer> buffer = new ABuffer(chunk_data_size + 1);
17561760
if (mDataSource->readAt(
17571761
data_offset, buffer->data(), chunk_data_size) != (ssize_t)chunk_data_size) {

0 commit comments

Comments
 (0)