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

0024759: Crash on STEP import, when reading a file exported in non-"C" locale

Fix for step reading: protection against memory buffer overrun when parsing list of reals written with comma as radix
This commit is contained in:
dbv 2014-04-08 19:19:21 +04:00 committed by abv
parent fc8a8f4cb1
commit e79807c77f

View File

@ -52,8 +52,8 @@ void RWStepGeom_RWCartesianPoint::ReadStep
if(nb2 > 3) {
ach->AddWarning("More than 3 coordinates, ignored");
}
nbcoord = nb2;
for (Standard_Integer i2 = 0; i2 < nb2; i2 ++) {
nbcoord = Min (nb2, 3);
for (Standard_Integer i2 = 0; i2 < nbcoord; i2 ++) {
if (data->ReadReal (nsub2,i2+1,"coordinates",ach,aCoordinatesItem)) {
XYZ[i2] = aCoordinatesItem;
}
@ -64,7 +64,7 @@ void RWStepGeom_RWCartesianPoint::ReadStep
// ent->Init(aName, aCoordinates);
if (nbcoord >= 3) ent->Init3D (aName, XYZ[0],XYZ[1],XYZ[2]);
if (nbcoord == 3) ent->Init3D (aName, XYZ[0],XYZ[1],XYZ[2]);
else ent->Init2D (aName, XYZ[0],XYZ[1]);
}