Hardened against reads in the IRMemoryMap that

exceed the bounds of the backing memory.

<rdar://problem/16088322>

llvm-svn: 202899
This commit is contained in:
Sean Callanan 2014-03-04 21:56:11 +00:00
parent 5a09527d0d
commit 9bbf3cd3d7
1 changed files with 14 additions and 0 deletions

View File

@ -576,6 +576,13 @@ IRMemoryMap::ReadMemory (uint8_t *bytes, lldb::addr_t process_address, size_t si
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, lldb::addr_t process_address, size_t si
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: