diff options
author | Jason Molenda <jmolenda@apple.com> | 2017-03-21 04:34:17 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2017-03-21 04:34:17 +0000 |
commit | 3724ae4e7092c8145e22f5f1fbe4825c0682b907 (patch) | |
tree | b50f62826023273884046ad1031cc11743adaa6b /lldb/source | |
parent | 23be94599db55d946cb66d00e425e117d29f6cf1 (diff) | |
download | bcm5719-llvm-3724ae4e7092c8145e22f5f1fbe4825c0682b907.tar.gz bcm5719-llvm-3724ae4e7092c8145e22f5f1fbe4825c0682b907.zip |
Fix two places where an arm instruction emulation method
can dereference misaligned memory.
<rdar://problem/31106315>, <rdar://problem/31106337>
llvm-svn: 298337
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp index 9ceeb76c6f5..7b10f8ffadb 100644 --- a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp +++ b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp @@ -192,15 +192,18 @@ size_t EmulationStateARM::WritePseudoMemory( EmulationStateARM *pseudo_state = (EmulationStateARM *)baton; if (length <= 4) { - uint32_t value = *((const uint32_t *)dst); + uint32_t value; + memcpy (&value, dst, sizeof (uint32_t)); if (endian::InlHostByteOrder() == lldb::eByteOrderBig) value = llvm::ByteSwap_32(value); pseudo_state->StoreToPseudoAddress(addr, value); return length; } else if (length == 8) { - uint32_t value1 = ((const uint32_t *)dst)[0]; - uint32_t value2 = ((const uint32_t *)dst)[1]; + uint32_t value1; + uint32_t value2; + memcpy (&value1, dst, sizeof (uint32_t)); + memcpy (&value2, (uint8_t *) dst + sizeof (uint32_t), sizeof (uint32_t)); if (endian::InlHostByteOrder() == lldb::eByteOrderBig) { value1 = llvm::ByteSwap_32(value1); value2 = llvm::ByteSwap_32(value2); |