Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- media/libstagefright/MPEG4Extractor.cpp.orig 2015-08-07 18:45:05.660506138 +0200
- +++ media/libstagefright/MPEG4Extractor.cpp 2015-08-10 07:05:39.057882612 +0200
- @@ -834,6 +834,9 @@
- }
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->sampleTable = new SampleTable(mDataSource);
- }
- @@ -982,6 +985,10 @@
- }
- original_fourcc = ntohl(original_fourcc);
- ALOGV("read original format: %d", original_fourcc);
- +
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(original_fourcc));
- uint32_t num_channels = 0;
- uint32_t sample_rate = 0;
- @@ -1036,6 +1043,9 @@
- return ERROR_IO;
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->meta->setInt32(kKeyCryptoMode, defaultAlgorithmId);
- mLastTrack->meta->setInt32(kKeyCryptoDefaultIVSize, defaultIVSize);
- mLastTrack->meta->setData(kKeyCryptoKey, 'tenc', defaultKeyId, 16);
- @@ -1137,8 +1147,10 @@
- duration = ntohl(duration32);
- }
- }
- - mLastTrack->meta->setInt64(
- + if (duration != 0 && mLastTrack->timescale != 0) {
- + mLastTrack->meta->setInt64(
- kKeyDuration, (duration * 1000000) / mLastTrack->timescale);
- + }
- uint8_t lang[2];
- off64_t lang_offset;
- @@ -1200,6 +1212,10 @@
- // display the timed text.
- // For encrypted files, there may also be more than one entry.
- const char *mime;
- +
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime));
- if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) &&
- strcasecmp(mime, "application/octet-stream")) {
- @@ -1246,6 +1262,9 @@
- uint16_t sample_size = U16_AT(&buffer[18]);
- uint32_t sample_rate = U32_AT(&buffer[24]) >> 16;
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- if (chunk_type != FOURCC('e', 'n', 'c', 'a')) {
- // if the chunk type is enca, we'll get the type from the sinf/frma box later
- mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type));
- @@ -1305,6 +1324,9 @@
- // printf("*** coding='%s' width=%d height=%d\n",
- // chunk, width, height);
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- if (chunk_type != FOURCC('e', 'n', 'c', 'v')) {
- // if the chunk type is encv, we'll get the type from the sinf/frma box later
- mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type));
- @@ -1330,6 +1352,9 @@
- case FOURCC('s', 't', 'c', 'o'):
- case FOURCC('c', 'o', '6', '4'):
- {
- + if (!mLastTrack || !mLastTrack->sampleTable.get())
- + return ERROR_MALFORMED;
- +
- status_t err =
- mLastTrack->sampleTable->setChunkOffsetParams(
- chunk_type, data_offset, chunk_data_size);
- @@ -1344,6 +1369,9 @@
- case FOURCC('s', 't', 's', 'c'):
- {
- + if (!mLastTrack || !mLastTrack->sampleTable.get())
- + return ERROR_MALFORMED;
- +
- status_t err =
- mLastTrack->sampleTable->setSampleToChunkParams(
- data_offset, chunk_data_size);
- @@ -1359,6 +1387,9 @@
- case FOURCC('s', 't', 's', 'z'):
- case FOURCC('s', 't', 'z', '2'):
- {
- + if (!mLastTrack || !mLastTrack->sampleTable.get())
- + return ERROR_MALFORMED;
- +
- status_t err =
- mLastTrack->sampleTable->setSampleSizeParams(
- chunk_type, data_offset, chunk_data_size);
- @@ -1441,6 +1472,9 @@
- case FOURCC('c', 't', 't', 's'):
- {
- + if (!mLastTrack || !mLastTrack->sampleTable.get())
- + return ERROR_MALFORMED;
- +
- status_t err =
- mLastTrack->sampleTable->setCompositionTimeToSampleParams(
- data_offset, chunk_data_size);
- @@ -1455,6 +1489,9 @@
- case FOURCC('s', 't', 's', 's'):
- {
- + if (!mLastTrack || !mLastTrack->sampleTable.get())
- + return ERROR_MALFORMED;
- +
- status_t err =
- mLastTrack->sampleTable->setSyncSampleParams(
- data_offset, chunk_data_size);
- @@ -1523,6 +1560,9 @@
- return ERROR_MALFORMED;
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->meta->setData(
- kKeyESDS, kTypeESDS, &buffer[4], chunk_data_size - 4);
- @@ -1554,6 +1594,9 @@
- return ERROR_IO;
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->meta->setData(
- kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size);
- @@ -1586,6 +1629,9 @@
- return ERROR_IO;
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->meta->setData(kKeyD263, kTypeD263, buffer, chunk_data_size);
- *offset += chunk_size;
- @@ -1702,6 +1748,10 @@
- return ERROR_IO;
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- +
- uint32_t type = ntohl(buffer);
- // For the 3GPP file format, the handler-type within the 'hdlr' box
- // shall be 'text'. We also want to support 'sbtl' handler type
- @@ -1716,6 +1766,9 @@
- case FOURCC('t', 'x', '3', 'g'):
- {
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- uint32_t type;
- const void *data;
- size_t size = 0;
- @@ -1738,6 +1791,9 @@
- return ERROR_IO;
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->meta->setData(
- kKeyTextFormatData, 0, buffer, size + chunk_size);
- @@ -1752,12 +1808,17 @@
- 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;
- sp<ABuffer> buffer = new ABuffer(chunk_data_size + 1);
- if (mDataSource->readAt(
- data_offset, buffer->data(), chunk_data_size) != (ssize_t)chunk_data_size) {
- return ERROR_IO;
- }
- const int kSkipBytesOfDataBox = 16;
- + if (chunk_data_size <= kSkipBytesOfDataBox)
- + return ERROR_MALFORMED;
- mFileMetaData->setData(
- kKeyAlbumArt, MetaData::TYPE_NONE,
- buffer->data() + kSkipBytesOfDataBox, chunk_data_size - kSkipBytesOfDataBox);
- @@ -1785,6 +1846,9 @@
- default:
- {
- + if (!mLastTrack || !mLastTrack->sampleTable.get())
- + return ERROR_MALFORMED;
- +
- *offset += chunk_size;
- break;
- }
- @@ -1819,6 +1883,8 @@
- if (!mDataSource->getUInt32(offset + 8, &timeScale)) {
- return ERROR_MALFORMED;
- }
- + if (timeScale < 1)
- + return ERROR_MALFORMED;
- ALOGV("sidx refid/timescale: %d/%d", referenceId, timeScale);
- uint64_t earliestPresentationTime;
- @@ -1903,6 +1969,9 @@
- mSidxDuration = total_duration * 1000000 / timeScale;
- ALOGV("duration: %lld", mSidxDuration);
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- int64_t metaDuration;
- if (!mLastTrack->meta->findInt64(kKeyDuration, &metaDuration) || metaDuration == 0) {
- mLastTrack->meta->setInt64(kKeyDuration, mSidxDuration);
- @@ -1953,6 +2022,9 @@
- return ERROR_UNSUPPORTED;
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->meta->setInt32(kKeyTrackID, id);
- size_t matrixOffset = dynSize + 16;
- @@ -2131,6 +2203,9 @@
- int32_t delay, padding;
- if (sscanf(mLastCommentData,
- " %*x %x %x %*x", &delay, &padding) == 2) {
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->meta->setInt32(kKeyEncoderDelay, delay);
- mLastTrack->meta->setInt32(kKeyEncoderPadding, padding);
- }
- @@ -2255,6 +2330,9 @@
- if (objectTypeIndication == 0xe1) {
- // This isn't MPEG4 audio at all, it's QCELP 14k...
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_QCELP);
- return OK;
- }
- @@ -2303,6 +2381,9 @@
- objectType = 32 + br.getBits(6);
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- //keep AOT type
- mLastTrack->meta->setInt32(kKeyAACAOT, objectType);
- @@ -2348,6 +2429,9 @@
- return ERROR_UNSUPPORTED;
- }
- + if (!mLastTrack)
- + return ERROR_MALFORMED;
- +
- int32_t prevSampleRate;
- CHECK(mLastTrack->meta->findInt32(kKeySampleRate, &prevSampleRate));
- --- media/libstagefright/SampleTable.cpp.orig 2015-08-07 18:45:05.664506138 +0200
- +++ media/libstagefright/SampleTable.cpp 2015-08-10 06:54:36.517866214 +0200
- @@ -230,8 +230,13 @@
- return ERROR_MALFORMED;
- }
- + if (SIZE_MAX / sizeof(SampleToChunkEntry) <= mNumSampleToChunkOffsets)
- + return ERROR_OUT_OF_RANGE;
- +
- mSampleToChunkEntries =
- - new SampleToChunkEntry[mNumSampleToChunkOffsets];
- + new (std::nothrow) SampleToChunkEntry[mNumSampleToChunkOffsets];
- + if (!mSampleToChunkEntries)
- + return ERROR_OUT_OF_RANGE;
- for (uint32_t i = 0; i < mNumSampleToChunkOffsets; ++i) {
- uint8_t buffer[12];
- @@ -331,6 +336,10 @@
- mTimeToSampleCount = U32_AT(&header[4]);
- mTimeToSample = new uint32_t[mTimeToSampleCount * 2];
- + mTimeToSample = new (std::nothrow) uint32_t[mTimeToSampleCount * 2];
- + if (!mTimeToSample)
- + return ERROR_OUT_OF_RANGE;
- +
- size_t size = sizeof(uint32_t) * mTimeToSampleCount * 2;
- if (mDataSource->readAt(
- @@ -373,6 +382,10 @@
- mNumCompositionTimeDeltaEntries = numEntries;
- mCompositionTimeDeltaEntries = new uint32_t[2 * numEntries];
- + mCompositionTimeDeltaEntries = new (std::nothrow) uint32_t[2 * numEntries];
- + if (!mCompositionTimeDeltaEntries)
- + return ERROR_OUT_OF_RANGE;
- +
- if (mDataSource->readAt(
- data_offset + 8, mCompositionTimeDeltaEntries, numEntries * 8)
- @@ -417,7 +430,10 @@
- ALOGV("Table of sync samples is empty or has only a single entry!");
- }
- - mSyncSamples = new uint32_t[mNumSyncSamples];
- + mSyncSamples = new (std::nothrow) uint32_t[mNumSyncSamples];
- + if (!mSyncSamples)
- + return ERROR_OUT_OF_RANGE;
- +
- size_t size = mNumSyncSamples * sizeof(uint32_t);
- if (mDataSource->readAt(mSyncSampleOffset + 8, mSyncSamples, size)
- != (ssize_t)size) {
- @@ -485,7 +501,9 @@
- return;
- }
- - mSampleTimeEntries = new SampleTimeEntry[mNumSampleSizes];
- + mSampleTimeEntries = new (std::nothrow) SampleTimeEntry[mNumSampleSizes];
- + if (!mSampleTimeEntries)
- + return;
- uint32_t sampleIndex = 0;
- uint32_t sampleTime = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement