const unsigned SegmentLoadSize = sizeof(SegmentCmd);
if (Load.C.cmdsize < SegmentLoadSize)
return object_error::macho_load_segment_too_small;
- SegmentCmd S = getStruct<SegmentCmd>(Obj, Load.Ptr);
+ auto SegOrErr = getStructOrErr<SegmentCmd>(Obj, Load.Ptr);
+ if (!SegOrErr)
+ return SegOrErr.getError();
+ SegmentCmd S = SegOrErr.get();
const unsigned SectionSize =
Obj->is64Bit() ? sizeof(MachO::section_64) : sizeof(MachO::section);
if (S.nsects > std::numeric_limits<uint32_t>::max() / SectionSize ||
RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s
INVALID-HEADER: Invalid data was encountered while parsing the file
+
+RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s
+INCOMPLETE-SEGMENT-LOADC: Invalid data was encountered while parsing the file