Commit dffe881f authored by Pawin Vongmasa's avatar Pawin Vongmasa Committed by The Android Automerger
Browse files

SampleTable.cpp: Fixed a regression caused by a fix for bug

28076789.

Detail: Before the original fix
(Id207f369ab7b27787d83f5d8fc48dc53ed9fcdc9) for 28076789, the
code allowed a time-to-sample table size to be 0. The change
made in that fix disallowed such situation, which in fact should
be allowed. This current patch allows it again while maintaining
the security of the previous fix.

Bug: 28288202
Bug: 28076789
Change-Id: I1c9a60c7f0cfcbd3d908f24998dde15d5136a295
parent f6bdce87
......@@ -121,6 +121,7 @@ SampleTable::SampleTable(const sp<DataSource> &source)
mSampleSizeFieldSize(0),
mDefaultSampleSize(0),
mNumSampleSizes(0),
mHasTimeToSample(false),
mTimeToSampleCount(0),
mTimeToSample(),
mSampleTimeEntries(NULL),
......@@ -159,7 +160,7 @@ bool SampleTable::isValid() const {
return mChunkOffsetOffset >= 0
&& mSampleToChunkOffset >= 0
&& mSampleSizeOffset >= 0
&& !mTimeToSample.empty();
&& mHasTimeToSample;
}
status_t SampleTable::setChunkOffsetParams(
......@@ -322,7 +323,7 @@ status_t SampleTable::setSampleSizeParams(
status_t SampleTable::setTimeToSampleParams(
off64_t data_offset, size_t data_size) {
if (!mTimeToSample.empty() || data_size < 8) {
if (mHasTimeToSample || data_size < 8) {
return ERROR_MALFORMED;
}
......@@ -361,6 +362,8 @@ status_t SampleTable::setTimeToSampleParams(
for (size_t i = 0; i < mTimeToSample.size(); ++i) {
mTimeToSample.editItemAt(i) = ntohl(mTimeToSample[i]);
}
mHasTimeToSample = true;
return OK;
}
......
......@@ -111,6 +111,7 @@ private:
uint32_t mDefaultSampleSize;
uint32_t mNumSampleSizes;
bool mHasTimeToSample;
uint32_t mTimeToSampleCount;
Vector<uint32_t> mTimeToSample;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment