[Lldb-commits] [PATCH] D44042: Ensure that trailing characters aren't included in PECOFF section names
Francis Ricci via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 2 12:46:19 PST 2018
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44042.136832.patch
Type: text/x-patch
Size: 500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180302/cc89f633/attachment.bin>
More information about the lldb-commits
mailing list