Make error skipping in EBML parser configurable
This commit is contained in:
parent
0d39a70b5f
commit
98fc83af6a
|
@ -27,6 +27,11 @@ namespace Media {
|
|||
* \brief The EbmlElement class helps to parse EBML files such as Matroska files.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Specifies the number of bytes to be skipped till a valid EBML element is found in the stream.
|
||||
*/
|
||||
uint64 EbmlElement::bytesToBeSkipped = 0x4000;
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new top level element with the specified \a container at the specified \a startOffset.
|
||||
*/
|
||||
|
@ -53,7 +58,7 @@ EbmlElement::EbmlElement(EbmlElement &parent, uint64 startOffset) :
|
|||
*/
|
||||
string EbmlElement::parsingContext() const
|
||||
{
|
||||
return "parsing header of EBML element " % idToString() % " at " + numberToString(startOffset());
|
||||
return ("parsing header of EBML element " % idToString() % " at ") + startOffset();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -64,7 +69,7 @@ void EbmlElement::internalParse()
|
|||
invalidateStatus();
|
||||
static const string context("parsing EBML element header");
|
||||
|
||||
for(byte skipped = 0; /* TODO: add a sane limit here */; ++m_startOffset, --m_maxSize, ++skipped) {
|
||||
for(uint64 skipped = 0; skipped < bytesToBeSkipped; ++m_startOffset, --m_maxSize, ++skipped) {
|
||||
// check whether max size is valid
|
||||
if(maxTotalSize() < 2) {
|
||||
addNotification(NotificationType::Critical, argsToString("The EBML element at ", startOffset(), " is truncated or does not exist."), context);
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
static void makeSimpleElement(std::ostream &stream, identifierType id, uint64 content);
|
||||
static void makeSimpleElement(std::ostream &stream, identifierType id, const std::string &content);
|
||||
static void makeSimpleElement(std::ostream &stream, GenericFileElement::identifierType id, const char *data, std::size_t dataSize);
|
||||
static uint64 bytesToBeSkipped;
|
||||
|
||||
protected:
|
||||
EbmlElement(EbmlElement &parent, uint64 startOffset);
|
||||
|
|
Loading…
Reference in New Issue