Skip to content

Commit 23927df

Browse files
Pawin Vongmasaandi34
authored andcommitted
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
1 parent 1983979 commit 23927df

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

media/libstagefright/SampleTable.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ SampleTable::SampleTable(const sp<DataSource> &source)
121121
mSampleSizeFieldSize(0),
122122
mDefaultSampleSize(0),
123123
mNumSampleSizes(0),
124+
mHasTimeToSample(false),
124125
mTimeToSampleCount(0),
125126
mTimeToSample(),
126127
mSampleTimeEntries(NULL),
@@ -159,7 +160,7 @@ bool SampleTable::isValid() const {
159160
return mChunkOffsetOffset >= 0
160161
&& mSampleToChunkOffset >= 0
161162
&& mSampleSizeOffset >= 0
162-
&& !mTimeToSample.empty();
163+
&& mHasTimeToSample;
163164
}
164165

165166
status_t SampleTable::setChunkOffsetParams(
@@ -322,7 +323,7 @@ status_t SampleTable::setSampleSizeParams(
322323

323324
status_t SampleTable::setTimeToSampleParams(
324325
off64_t data_offset, size_t data_size) {
325-
if (!mTimeToSample.empty() || data_size < 8) {
326+
if (mHasTimeToSample || data_size < 8) {
326327
return ERROR_MALFORMED;
327328
}
328329

@@ -361,6 +362,8 @@ status_t SampleTable::setTimeToSampleParams(
361362
for (size_t i = 0; i < mTimeToSample.size(); ++i) {
362363
mTimeToSample.editItemAt(i) = ntohl(mTimeToSample[i]);
363364
}
365+
366+
mHasTimeToSample = true;
364367
return OK;
365368
}
366369

media/libstagefright/include/SampleTable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class SampleTable : public RefBase {
109109
uint32_t mDefaultSampleSize;
110110
uint32_t mNumSampleSizes;
111111

112+
bool mHasTimeToSample;
112113
uint32_t mTimeToSampleCount;
113114
Vector<uint32_t> mTimeToSample;
114115

0 commit comments

Comments
 (0)