[Lldb-commits] [PATCH] D44042: Ensure that trailing characters aren't included in PECOFF section names

2018-03-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Will we have the same problem with coff_symbol?


https://reviews.llvm.org/D44042



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44042: Ensure that trailing characters aren't included in PECOFF section names

2018-03-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added inline comments.
This revision now requires changes to proceed.



Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:511
+  // necessarily null-terminated
+  sect_name = std::string(sect.name, sizeof(sect.name));
   return true;

This is storing any extra NULL characters in sect_name. Might be better to do:

```
sect_name = std::string(sect.name, strnlen(sect.name, sizeof(sect.name)));
```


https://reviews.llvm.org/D44042



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44042: Ensure that trailing characters aren't included in PECOFF section names

2018-03-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Add test as well.


https://reviews.llvm.org/D44042



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44042: Ensure that trailing characters aren't included in PECOFF section names

2018-03-02 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment.

Just compile something with /Z7 and you'll get a section called `.debug$S` in 
the object file, which is exactly 8 characters.  Then teach lldb-test to dump 
an object file's sections.


https://reviews.llvm.org/D44042



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44042: Ensure that trailing characters aren't included in PECOFF section names

2018-03-02 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Is it possible to test this? Is it possible to make yaml2obj generate a file 
that would trigger this?


https://reviews.llvm.org/D44042



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44042: Ensure that trailing characters aren't included in PECOFF section names

2018-03-02 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

good catch


https://reviews.llvm.org/D44042



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44042: Ensure that trailing characters aren't included in PECOFF section names

2018-03-02 Thread Francis Ricci via Phabricator via lldb-commits
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