[Lldb-commits] [lldb] r206865 - When increasing the amount of a file read, read the total of the Mach-O header

Jason Molenda jmolenda at apple.com
Mon Apr 21 21:52:31 PDT 2014


Author: jmolenda
Date: Mon Apr 21 23:52:30 2014
New Revision: 206865

URL: http://llvm.org/viewvc/llvm-project?rev=206865&view=rev
Log:
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> 

Modified:
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=206865&r1=206864&r2=206865&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Mon Apr 21 23:52:30 2014
@@ -636,9 +636,10 @@ ObjectFileMachO::GetModuleSpecifications
         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);
             }





More information about the lldb-commits mailing list