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

Commit c80241d9 authored by Marco Nelissen's avatar Marco Nelissen Committed by android-build-merger
Browse files

Limit mp4 atom size to something reasonable am: cb898dca am: 3a8c3030 am: 75e5b60a

am: 828c7c2c

Change-Id: I28eec82a69d9f29cf5d26ac0f034397e7ffb7343
parents b87e75a6 828c7c2c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -50,6 +50,12 @@

namespace android {

enum {
    // maximum size of an atom. Some atoms can be bigger according to the spec,
    // but we only allow up to this size.
    kMaxAtomSize = 64 * 1024 * 1024,
};

class MPEG4Source : public MediaSource {
public:
    // Caller retains ownership of both "dataSource" and "sampleTable".
@@ -836,6 +842,13 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
    PathAdder autoAdder(&mPath, chunk_type);

    off64_t chunk_data_size = *offset + chunk_size - data_offset;
    if (chunk_type != FOURCC('m', 'd', 'a', 't') && chunk_data_size > kMaxAtomSize) {
        char errMsg[100];
        sprintf(errMsg, "%s atom has size %" PRId64, chunk, chunk_data_size);
        ALOGE("%s (b/28615448)", errMsg);
        android_errorWriteWithInfoLog(0x534e4554, "28615448", -1, errMsg, strlen(errMsg));
        return ERROR_MALFORMED;
    }

    if (chunk_type != FOURCC('c', 'p', 'r', 't')
            && chunk_type != FOURCC('c', 'o', 'v', 'r')