Next set of additional error checks for invalid Mach-O files for bad LC_UUID

load commands.  Added a missing check and made the check for more than
one like other other “more than one” checks.  And of course added test cases.

llvm-svn: 282104
This commit is contained in:
Kevin Enderby
2016-09-21 20:03:09 +00:00
parent 1ac2f2c4d3
commit e71e13c7d6
4 changed files with 12 additions and 2 deletions

View File

@@ -717,9 +717,13 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
"LC_DYLD_INFO_ONLY")))
return;
} else if (Load.C.cmd == MachO::LC_UUID) {
// Multiple UUID load commands
if (Load.C.cmdsize != sizeof(MachO::uuid_command)) {
Err = malformedError("LC_UUID command " + Twine(I) + " has incorrect "
"cmdsize");
return;
}
if (UuidLoadCmd) {
Err = malformedError("Multiple UUID load commands");
Err = malformedError("more than one LC_UUID command");
return;
}
UuidLoadCmd = Load.Ptr;