When increasing the amount of a file read, read the total of the Mach-O header
plus the size of the load commands in case the LC_UUID load command comes near
the end of the file.
<rdar://problem/16599318>
llvm-svn: 206865
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index ed80c63..4f491ce 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -636,9 +636,10 @@
llvm::MachO::mach_header header;
if (ParseHeader (data, &data_offset, header))
{
- if (header.sizeofcmds >= data_sp->GetByteSize())
+ size_t header_and_load_cmds = header.sizeofcmds + MachHeaderSizeFromMagic(header.magic);
+ if (header_and_load_cmds >= data_sp->GetByteSize())
{
- data_sp = file.ReadFileContents(file_offset, header.sizeofcmds);
+ data_sp = file.ReadFileContents(file_offset, header_and_load_cmds);
data.SetData(data_sp);
data_offset = MachHeaderSizeFromMagic(header.magic);
}