Commit eeb73a86 by Oliver Woodman

Improve sniffer behavior for fragmented MP4.

- Allow a moof box to exceed the search size.
- Return immediately after reading an ftyp box with no compatible types.

Issue: #784
parent 6f9019a4
......@@ -102,13 +102,9 @@ 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) {
return false;
}
// Stop searching if reading this atom would exceed the search limit.
if (bytesSearched + atomSize > bytesToSearch) {
break;
}
int atomDataSize = (int) atomSize - headerSize;
if (atomType == Atom.TYPE_ftyp) {
if (atomDataSize < 8) {
......@@ -126,10 +122,18 @@ import java.io.IOException;
break;
}
}
// There is only one ftyp box, so reject the file if the file type in this box was invalid.
if (!foundGoodFileType) {
return false;
}
} else if (atomType == Atom.TYPE_moof) {
foundFragment = true;
break;
} else if (atomDataSize != 0) {
// Stop searching if reading this atom would exceed the search limit.
if (bytesSearched + atomSize >= bytesToSearch) {
break;
}
input.advancePeekPosition(atomDataSize);
}
bytesSearched += atomSize;
......
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 sign in to comment