[Lldb-commits] [lldb] r202899 - Hardened against reads in the IRMemoryMap that

Sean Callanan scallanan at apple.com
Tue Mar 4 13:56:11 PST 2014


Author: spyffe
Date: Tue Mar  4 15:56:11 2014
New Revision: 202899

URL: http://llvm.org/viewvc/llvm-project?rev=202899&view=rev
Log:
Hardened against reads in the IRMemoryMap that
exceed the bounds of the backing memory.

<rdar://problem/16088322>

Modified:
    lldb/trunk/source/Expression/IRMemoryMap.cpp

Modified: lldb/trunk/source/Expression/IRMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRMemoryMap.cpp?rev=202899&r1=202898&r2=202899&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRMemoryMap.cpp (original)
+++ lldb/trunk/source/Expression/IRMemoryMap.cpp Tue Mar  4 15:56:11 2014
@@ -576,6 +576,13 @@ IRMemoryMap::ReadMemory (uint8_t *bytes,
     
     uint64_t offset = process_address - allocation.m_process_start;
     
+    if (offset > allocation.m_size)
+    {
+        error.SetErrorToGenericError();
+        error.SetErrorString("Couldn't read: data is not in the allocation");
+        return;
+    }
+    
     lldb::ProcessSP process_sp;
     
     switch (allocation.m_policy)
@@ -591,6 +598,13 @@ IRMemoryMap::ReadMemory (uint8_t *bytes,
             error.SetErrorString("Couldn't read: data buffer is empty");
             return;
         }
+        if (allocation.m_data.GetByteSize() < offset + size)
+        {
+            error.SetErrorToGenericError();
+            error.SetErrorString("Couldn't read: not enough underlying data");
+            return;
+        }
+
         ::memcpy (bytes, allocation.m_data.GetBytes() + offset, size);
         break;
     case eAllocationPolicyMirror:





More information about the lldb-commits mailing list