mirror of
https://github.com/androidx/media.git
synced 2025-05-11 17:49:52 +08:00
Fix an unsafe check in FragmentedMp4Extractor.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=111315463
This commit is contained in:
parent
81a74af933
commit
030f26fd2d
@ -693,22 +693,22 @@ public final class FragmentedMp4Extractor implements Extractor {
|
||||
* @throws InterruptedException If the thread is interrupted.
|
||||
*/
|
||||
private boolean readSample(ExtractorInput input) throws IOException, InterruptedException {
|
||||
if (sampleIndex == 0) {
|
||||
int bytesToSkip = (int) (fragmentRun.dataPosition - input.getPosition());
|
||||
checkState(bytesToSkip >= 0, "Offset to sample data was negative.");
|
||||
input.skipFully(bytesToSkip);
|
||||
}
|
||||
|
||||
if (sampleIndex >= fragmentRun.length) {
|
||||
int bytesToSkip = (int) (endOfMdatPosition - input.getPosition());
|
||||
checkState(bytesToSkip >= 0, "Offset to end of mdat was negative.");
|
||||
input.skipFully(bytesToSkip);
|
||||
// We've run out of samples in the current mdat atom.
|
||||
enterReadingAtomHeaderState();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parserState == STATE_READING_SAMPLE_START) {
|
||||
if (sampleIndex == fragmentRun.length) {
|
||||
// We've run out of samples in the current mdat. Discard any trailing data and prepare to
|
||||
// read the header of the next atom.
|
||||
int bytesToSkip = (int) (endOfMdatPosition - input.getPosition());
|
||||
checkState(bytesToSkip >= 0, "Offset to end of mdat was negative.");
|
||||
input.skipFully(bytesToSkip);
|
||||
enterReadingAtomHeaderState();
|
||||
return false;
|
||||
}
|
||||
if (sampleIndex == 0) {
|
||||
// We're reading the first sample in the current mdat. Discard any preceding data.
|
||||
int bytesToSkip = (int) (fragmentRun.dataPosition - input.getPosition());
|
||||
checkState(bytesToSkip >= 0, "Offset to sample data was negative.");
|
||||
input.skipFully(bytesToSkip);
|
||||
}
|
||||
sampleSize = fragmentRun.sampleSizeTable[sampleIndex];
|
||||
if (fragmentRun.definesEncryptionData) {
|
||||
sampleBytesWritten = appendSampleEncryptionData(fragmentRun.sampleEncryptionData);
|
||||
|
Loading…
x
Reference in New Issue
Block a user