1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0027667: OCAF binary persistence hangs on reading truncated CBF file

A check on "end of file" is added to the reader.
This commit is contained in:
vro 2017-05-22 15:41:14 +03:00 committed by bugmaster
parent 261b7d9e8a
commit 5ecc46c08e
2 changed files with 24 additions and 4 deletions

View File

@ -233,8 +233,15 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
do {
BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream);
mySections.Append(aSection);
} while
(!aSection.Name().IsEqual((Standard_CString)SHAPESECTION_POS));
} while(!aSection.Name().IsEqual((Standard_CString)SHAPESECTION_POS) && !theIStream.eof());
if (theIStream.eof()) {
// There is no shape section in the file.
WriteMessage (aMethStr + "error: shape section is not found");
myReaderStatus = PCDM_RS_ReaderException;
return;
}
aDocumentPos = theIStream.tellg(); // position of root label
BinLDrivers_VectorOfDocumentSection::Iterator anIterS (mySections);
@ -336,7 +343,8 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
// Read attributes:
theIS >> myPAtt;
while (theIS && myPAtt.TypeId() > 0 && // not an end marker ?
myPAtt.Id() > 0) { // not a garbage ?
myPAtt.Id() > 0 && // not a garbage ?
!theIS.eof()) {
// get a driver according to TypeId
Handle(BinMDF_ADriver) aDriver = myDrivers->GetDriver (myPAtt.TypeId());
if (!aDriver.IsNull()) {
@ -386,7 +394,7 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
#if DO_INVERSE
aTag = InverseInt (aTag);
#endif
while (theIS && aTag >= 0) { // not an end marker ?
while (theIS && aTag >= 0 && !theIS.eof()) { // not an end marker ?
// create sub-label
TDF_Label aLab = theLabel.FindChild (aTag, Standard_True);

12
tests/bugs/caf/bug27667 Normal file
View File

@ -0,0 +1,12 @@
puts "REQUIRED OCC27667 All: BinLDrivers_DocumentRetrievalDriver: error: shape section is not found"
puts "REQUIRED OCC27667 All: DDocStd_Open : Error"
puts "================"
puts "OCC27667"
puts "================"
puts ""
#######################################################################################
# OCAF binary persistence hangs on reading truncated CBF file
#######################################################################################
catch { Open [locate_data_file bug27667_broken_cbf.cbf] D }