mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Fix MP4+MKV sniffing to handle empty atoms / EBML elements.
Issue: #641
This commit is contained in:
parent
648f224d98
commit
6b03e6a17c
3 changed files with 9 additions and 6 deletions
|
|
@ -102,7 +102,7 @@ import java.io.IOException;
|
|||
atomSize = buffer.readLong();
|
||||
}
|
||||
// Check the atom size is large enough to include its header.
|
||||
if (atomSize <= headerSize || atomSize > Integer.MAX_VALUE) {
|
||||
if (atomSize < headerSize || atomSize > Integer.MAX_VALUE) {
|
||||
return false;
|
||||
}
|
||||
// Stop searching if reading this atom would exceed the search limit.
|
||||
|
|
@ -129,7 +129,7 @@ import java.io.IOException;
|
|||
} else if (atomType == Atom.TYPE_moof) {
|
||||
foundFragment = true;
|
||||
break;
|
||||
} else {
|
||||
} else if (atomDataSize != 0) {
|
||||
input.advancePeekPosition(atomDataSize);
|
||||
}
|
||||
bytesSearched += atomSize;
|
||||
|
|
|
|||
|
|
@ -76,11 +76,13 @@ import java.io.IOException;
|
|||
return false;
|
||||
}
|
||||
long size = readUint(input);
|
||||
if (size <= 0 || size > Integer.MAX_VALUE) {
|
||||
if (size < 0 || size > Integer.MAX_VALUE) {
|
||||
return false;
|
||||
}
|
||||
input.advancePeekPosition((int) size);
|
||||
peekLength += size;
|
||||
if (size != 0) {
|
||||
input.advancePeekPosition((int) size);
|
||||
peekLength += size;
|
||||
}
|
||||
}
|
||||
return peekLength == headerStart + headerSize;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1187,7 +1187,8 @@ public final class WebmExtractor implements Extractor {
|
|||
System.arraycopy(NalUnitUtil.NAL_START_CODE, 0, buffer, bufferPosition,
|
||||
NalUnitUtil.NAL_START_CODE.length);
|
||||
bufferPosition += NalUnitUtil.NAL_START_CODE.length;
|
||||
System.arraycopy(parent.data, parent.getPosition(), buffer, bufferPosition, nalUnitLength);
|
||||
System.arraycopy(parent.data, parent.getPosition(), buffer, bufferPosition,
|
||||
nalUnitLength);
|
||||
bufferPosition += nalUnitLength;
|
||||
parent.skipBytes(nalUnitLength);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue