]> OCCT Git - occt-copy.git/commitdiff
0024759: Crash on STEP import, when reading a file exported in non-"C" locale
authordbv <dbv@opencascade.com>
Tue, 8 Apr 2014 15:19:21 +0000 (19:19 +0400)
committerabv <abv@opencascade.com>
Wed, 9 Apr 2014 13:09:59 +0000 (17:09 +0400)
Fix for step reading: protection against memory buffer overrun when parsing list of reals written with comma as radix

src/RWStepGeom/RWStepGeom_RWCartesianPoint.cxx

index d2346960532700f2379abc79be08633db03ebf54..429f67e0f9741735737db94164b0986751d65c41 100644 (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]);
 }