diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2016-06-24 19:34:41 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2016-06-24 19:34:41 +0000 |
| commit | f15064871ad933370532f068eca70fb5134ba69f (patch) | |
| tree | ae7eda355b3a3189ed5bfc02260ea2b26ace74fa /llvm/lib/DebugInfo | |
| parent | b8503d5399d0693e49e731d96ca06ce22e425c2b (diff) | |
| download | bcm5719-llvm-f15064871ad933370532f068eca70fb5134ba69f.tar.gz bcm5719-llvm-f15064871ad933370532f068eca70fb5134ba69f.zip | |
[CodeView] Healthy paranoia around strings
Make sure strings don't get too big for a record, truncate them if
need-be.
llvm-svn: 273710
Diffstat (limited to 'llvm/lib/DebugInfo')
| -rw-r--r-- | llvm/lib/DebugInfo/CodeView/ListRecordBuilder.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/CodeView/TypeRecordBuilder.cpp | 11 |
2 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/ListRecordBuilder.cpp b/llvm/lib/DebugInfo/CodeView/ListRecordBuilder.cpp index dc72f500c87..eb79e8ac9a3 100644 --- a/llvm/lib/DebugInfo/CodeView/ListRecordBuilder.cpp +++ b/llvm/lib/DebugInfo/CodeView/ListRecordBuilder.cpp @@ -49,8 +49,10 @@ void ListRecordBuilder::finishSubRecord() { // back up and insert a continuation record, sliding the current subrecord // down. if (getLastContinuationSize() > 65535 - 8) { + assert(SubrecordStart != 0 && "can't slide from the start!"); SmallString<128> SubrecordCopy( Builder.str().slice(SubrecordStart, Builder.size())); + assert(SubrecordCopy.size() < 65530 && "subrecord is too large to slide!"); Builder.truncate(SubrecordStart); // Write a placeholder continuation record. diff --git a/llvm/lib/DebugInfo/CodeView/TypeRecordBuilder.cpp b/llvm/lib/DebugInfo/CodeView/TypeRecordBuilder.cpp index f1c293e39fd..112612cc85e 100644 --- a/llvm/lib/DebugInfo/CodeView/TypeRecordBuilder.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeRecordBuilder.cpp @@ -91,15 +91,10 @@ void TypeRecordBuilder::writeEncodedUnsignedInteger(uint64_t Value) { } } -void TypeRecordBuilder::writeNullTerminatedString(const char *Value) { - assert(Value != nullptr); - - size_t Length = strlen(Value); - Stream.write(Value, Length); - writeUInt8(0); -} - void TypeRecordBuilder::writeNullTerminatedString(StringRef Value) { + // Microsoft's linker seems to have trouble with symbol names longer than + // 0xffd8 bytes. + Value = Value.substr(0, 0xffd8); Stream.write(Value.data(), Value.size()); writeUInt8(0); } |

