Browse Source

Merge pull request #1258 from v1kko/dev

Avoid reading beyond boundaries of arrays in readSTL.cpp
Jérémie Dumas 6 years ago
parent
commit
de91fdd9d0
1 changed files with 2 additions and 2 deletions
  1. 2 2
      include/igl/readSTL.cpp

+ 2 - 2
include/igl/readSTL.cpp

@@ -85,14 +85,14 @@ IGL_INLINE bool igl::readSTL(
 
 
   // Specifically 80 character header
   // Specifically 80 character header
   char header[80];
   char header[80];
-  char solid[80];
+  char solid[80] = {0};
   bool is_ascii = true;
   bool is_ascii = true;
   if(fread(header,1,80,stl_file) != 80)
   if(fread(header,1,80,stl_file) != 80)
   {
   {
     cerr<<"IOError: too short (1)."<<endl;
     cerr<<"IOError: too short (1)."<<endl;
     goto close_false;
     goto close_false;
   }
   }
-  sscanf(header,"%s",solid);
+  sscanf(header,"%79s",solid);
   if(string("solid") != solid)
   if(string("solid") != solid)
   {
   {
     // definitely **not** ascii 
     // definitely **not** ascii