forked from OSchip/llvm-project
[mach-o] Add checks that string literals in object files are zero terminated
llvm-svn: 209685
This commit is contained in:
parent
3e90e5f187
commit
81e105e8d6
|
|
@ -129,6 +129,14 @@ static error_code processSection(MachOFile &file, const Section §ion,
|
|||
offset = i + 2;
|
||||
}
|
||||
}
|
||||
if (offset != section.content.size()) {
|
||||
return make_dynamic_error_code(Twine("Section ") + section.segmentName
|
||||
+ "/" + section.sectionName
|
||||
+ " is supposed to contain 0x0000 "
|
||||
"terminated UTF16 strings, but the "
|
||||
"last string in the section is not zero "
|
||||
"terminated.");
|
||||
}
|
||||
}
|
||||
case llvm::MachO::S_COALESCED:
|
||||
case llvm::MachO::S_ZEROFILL:
|
||||
|
|
@ -144,6 +152,13 @@ static error_code processSection(MachOFile &file, const Section §ion,
|
|||
offset = i + 1;
|
||||
}
|
||||
}
|
||||
if (offset != section.content.size()) {
|
||||
return make_dynamic_error_code(Twine("Section ") + section.segmentName
|
||||
+ "/" + section.sectionName
|
||||
+ " has type S_CSTRING_LITERALS but the "
|
||||
"last string in the section is not zero "
|
||||
"terminated.");
|
||||
}
|
||||
break;
|
||||
case llvm::MachO::S_4BYTE_LITERALS:
|
||||
if ((section.content.size() % 4) != 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue