mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Next set of additional error checks for invalid Mach-O files for the
load command that uses the MachO::entry_point_command type but not used in llvm libObject code but used in llvm tool code. This includes just the LC_MAIN load command. llvm-svn: 282766
This commit is contained in:
parent
70d55cf1cb
commit
62874739b7
@ -751,6 +751,7 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
|
||||
const char *CodeSignDrsLoadCmd = nullptr;
|
||||
const char *VersLoadCmd = nullptr;
|
||||
const char *SourceLoadCmd = nullptr;
|
||||
const char *EntryPointLoadCmd = nullptr;
|
||||
for (unsigned I = 0; I < LoadCommandCount; ++I) {
|
||||
if (is64Bit()) {
|
||||
if (Load.C.cmdsize % 8 != 0) {
|
||||
@ -891,6 +892,17 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
|
||||
return;
|
||||
}
|
||||
SourceLoadCmd = Load.Ptr;
|
||||
} else if (Load.C.cmd == MachO::LC_MAIN) {
|
||||
if (Load.C.cmdsize != sizeof(MachO::entry_point_command)) {
|
||||
Err = malformedError("LC_MAIN command " + Twine(I) +
|
||||
" has incorrect cmdsize");
|
||||
return;
|
||||
}
|
||||
if (EntryPointLoadCmd) {
|
||||
Err = malformedError("more than one LC_MAIN command");
|
||||
return;
|
||||
}
|
||||
EntryPointLoadCmd = Load.Ptr;
|
||||
}
|
||||
if (I < LoadCommandCount - 1) {
|
||||
if (auto LoadOrErr = getNextLoadCommandInfo(this, I, Load))
|
||||
|
BIN
test/Object/Inputs/macho-invalid-entry-bad-size
Normal file
BIN
test/Object/Inputs/macho-invalid-entry-bad-size
Normal file
Binary file not shown.
BIN
test/Object/Inputs/macho-invalid-entry-more-than-one
Normal file
BIN
test/Object/Inputs/macho-invalid-entry-more-than-one
Normal file
Binary file not shown.
@ -328,3 +328,9 @@ INVALID-SOURCE-BAD-SIZE: macho-invalid-source-bad-size': truncated or malformed
|
||||
|
||||
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-source-more-than-one 2>&1 | FileCheck -check-prefix INVALID-SOURCE-MORE-THAN-ONE %s
|
||||
INVALID-SOURCE-MORE-THAN-ONE: macho-invalid-source-more-than-one': truncated or malformed object (more than one LC_SOURCE_VERSION command)
|
||||
|
||||
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-entry-bad-size 2>&1 | FileCheck -check-prefix INVALID-ENTRY-BAD-SIZE %s
|
||||
INVALID-ENTRY-BAD-SIZE: macho-invalid-entry-bad-size': truncated or malformed object (LC_MAIN command 0 has incorrect cmdsize)
|
||||
|
||||
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-entry-more-than-one 2>&1 | FileCheck -check-prefix INVALID-ENTRY-MORE-THAN-ONE %s
|
||||
INVALID-ENTRY-MORE-THAN-ONE: macho-invalid-entry-more-than-one': truncated or malformed object (more than one LC_MAIN command)
|
||||
|
Loading…
Reference in New Issue
Block a user