EbmlMaster::Read(): drop elements with unset values in SCOPE_FULL_DATA mode

This prevents elements that couldn't be read properly (e.g. due to
defective data) from being handed over to the calling code in at best
half initialized state. See https://trac.bunkus.org/ticket/1096
This commit is contained in:
Moritz Bunkus 2014-12-20 17:25:53 +01:00
parent 6ba868a49b
commit 8055be972c
2 changed files with 23 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2014-12-20 Moritz Bunkus <moritz@bunkus.org>
* EbmlMaster::Read(): when reading with SCOPE_ALL_DATA only those
elements that could successfully be read will be kept
(e.g. defective block groups will be dropped).
2014-12-19 Moritz Bunkus <moritz@bunkus.org>
* EbmlMemoryStream: add a new class for safe memory access that

View File

@ -433,16 +433,28 @@ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sCo
break;
}
} else {
// more logical to do it afterward
ElementList.push_back(ElementLevelA);
ElementLevelA->Read(inDataStream, EBML_CONTEXT(ElementLevelA), UpperEltFound, FoundElt, AllowDummyElt, ReadFully);
// Discard elements that couldn't be read properly if
// SCOPE_ALL_DATA has been requested. This can happen
// e.g. if block data is defective.
bool DeleteElement = true;
if (ElementLevelA->ValueIsSet() || (ReadFully != SCOPE_ALL_DATA)) {
ElementList.push_back(ElementLevelA);
DeleteElement = false;
}
// just in case
if (ElementLevelA->IsFiniteSize())
if (ElementLevelA->IsFiniteSize()) {
ElementLevelA->SkipData(inDataStream, EBML_CONTEXT(ElementLevelA));
else
if (DeleteElement)
delete ElementLevelA;
} else {
if (DeleteElement)
delete ElementLevelA;
break;
}
}
if (UpperEltFound > 0) {