forked from OSchip/llvm-project
[CodeView] Healthy paranoia around strings
Make sure strings don't get too big for a record, truncate them if need-be. llvm-svn: 273710
This commit is contained in:
parent
b8503d5399
commit
f15064871a
|
@ -50,7 +50,7 @@ private:
|
|||
return ContinuationOffsets.empty() ? 0 : ContinuationOffsets.back();
|
||||
}
|
||||
size_t getLastContinuationEnd() const { return Builder.size(); }
|
||||
unsigned getLastContinuationSize() const {
|
||||
size_t getLastContinuationSize() const {
|
||||
return getLastContinuationEnd() - getLastContinuationStart();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ public:
|
|||
void writeEncodedInteger(int64_t Value);
|
||||
void writeEncodedSignedInteger(int64_t Value);
|
||||
void writeEncodedUnsignedInteger(uint64_t Value);
|
||||
void writeNullTerminatedString(const char *Value);
|
||||
void writeNullTerminatedString(StringRef Value);
|
||||
void writeGuid(StringRef Guid);
|
||||
void writeBytes(StringRef Value) { Stream << Value; }
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue