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
This commit is contained in:
parent
6f9019a4e3
commit
eeb73a86ea
@ -102,13 +102,9 @@ import java.io.IOException;
|
|||||||
atomSize = buffer.readLong();
|
atomSize = buffer.readLong();
|
||||||
}
|
}
|
||||||
// Check the atom size is large enough to include its header.
|
// Check the atom size is large enough to include its header.
|
||||||
if (atomSize < headerSize || atomSize > Integer.MAX_VALUE) {
|
if (atomSize < headerSize) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Stop searching if reading this atom would exceed the search limit.
|
|
||||||
if (bytesSearched + atomSize > bytesToSearch) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int atomDataSize = (int) atomSize - headerSize;
|
int atomDataSize = (int) atomSize - headerSize;
|
||||||
if (atomType == Atom.TYPE_ftyp) {
|
if (atomType == Atom.TYPE_ftyp) {
|
||||||
if (atomDataSize < 8) {
|
if (atomDataSize < 8) {
|
||||||
@ -126,10 +122,18 @@ import java.io.IOException;
|
|||||||
break;
|
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) {
|
} else if (atomType == Atom.TYPE_moof) {
|
||||||
foundFragment = true;
|
foundFragment = true;
|
||||||
break;
|
break;
|
||||||
} else if (atomDataSize != 0) {
|
} else if (atomDataSize != 0) {
|
||||||
|
// Stop searching if reading this atom would exceed the search limit.
|
||||||
|
if (bytesSearched + atomSize >= bytesToSearch) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
input.advancePeekPosition(atomDataSize);
|
input.advancePeekPosition(atomDataSize);
|
||||||
}
|
}
|
||||||
bytesSearched += atomSize;
|
bytesSearched += atomSize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user