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

Commit bf928560 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Limit ogg packet size

A malformed ogg file might lace together a very large packet, which
could lead to out of memory conditions. Limit the packet size to
avoid this.

Bug: 36592202
Change-Id: I8650b3ec54a0de9ec302a7cbac296bb85efcfb3d
parent 922ad618
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -481,7 +481,21 @@ status_t MyVorbisExtractor::readNextPacket(MediaBuffer **out) {
            if (buffer != NULL) {
                fullSize += buffer->range_length();
            }
            MediaBuffer *tmp = new MediaBuffer(fullSize);
            if (fullSize > 16 * 1024 * 1024) { // arbitrary limit of 16 MB packet size
                if (buffer != NULL) {
                    buffer->release();
                }
                ALOGE("b/36592202");
                return ERROR_MALFORMED;
            }
            MediaBuffer *tmp = new (std::nothrow) MediaBuffer(fullSize);
            if (tmp == NULL) {
                if (buffer != NULL) {
                    buffer->release();
                }
                ALOGE("b/36592202");
                return ERROR_MALFORMED;
            }
            if (buffer != NULL) {
                memcpy(tmp->data(), buffer->data(), buffer->range_length());
                tmp->set_range(0, buffer->range_length());