fjricci created this revision.
fjricci added reviewers: clayborg, zturner, wallace.

If a section name is exactly 8 characters (the maximum section name length),
and the next item in the section header struct contains a non-zero value,
we would append garbage data to the end of the section name string due to the
lack of null-termination. Ensure that we don't construct the section name
with more than sizeof(sect.name) characters.


https://reviews.llvm.org/D44042

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp


Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -505,7 +505,10 @@
 
     return false;
   }
-  sect_name = sect.name;
+
+  // The section name has a max length of 8 characters, but isn't
+  // necessarily null-terminated
+  sect_name = std::string(sect.name, sizeof(sect.name));
   return true;
 }
 


Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -505,7 +505,10 @@
 
     return false;
   }
-  sect_name = sect.name;
+
+  // The section name has a max length of 8 characters, but isn't
+  // necessarily null-terminated
+  sect_name = std::string(sect.name, sizeof(sect.name));
   return true;
 }
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to