mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-19 02:42:58 +00:00
[CodeView] Healthy paranoia around strings
Make sure strings don't get too big for a record, truncate them if need-be. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273710 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
28ea97622f
commit
82c356cae4
@ -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…
x
Reference in New Issue
Block a user