Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a81b3779 authored by Joshua J. Drake's avatar Joshua J. Drake Committed by Nick Kralevich
Browse files

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.

(cherrypicked from commit 05ddc499)

Bug: 20923261
Change-Id: If09a02738759acdff8d95149bb9cb5f18a0a123e
parent 738a753a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1425,6 +1425,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
            if (mFileMetaData != NULL) {
                ALOGV("chunk_data_size = %lld and data_offset = %lld",
                        chunk_data_size, data_offset);
                if (chunk_data_size >= SIZE_MAX - 1) {
                    return ERROR_MALFORMED;
                }
                uint8_t *buffer = new uint8_t[chunk_data_size + 1];
                if (mDataSource->readAt(
                    data_offset, buffer, chunk_data_size) != (ssize_t)chunk_data_size) {