diff options
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index d9d19fa1e8e..c6643cb8c03 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -192,6 +192,10 @@ static Expected<MachOObjectFile::LoadCommandInfo> getFirstLoadCommandInfo(const MachOObjectFile *Obj) { unsigned HeaderSize = Obj->is64Bit() ? sizeof(MachO::mach_header_64) : sizeof(MachO::mach_header); + if (sizeof(MachOObjectFile::LoadCommandInfo) > Obj->getHeader().sizeofcmds) + return malformedError(*Obj, "truncated or malformed object (load command " + "0 extends past the end all load commands in the " + "file)"); return getLoadCommandInfo(Obj, getPtr(Obj, HeaderSize)); } |