[Lldb-commits] [lldb] ab6a082 - [LLDB] Fix out-of-bounds memory access in EmulationStateArm
Slava Gurevich via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 11 01:34:28 PDT 2022
Author: Slava Gurevich
Date: 2022-08-11T01:34:18-07:00
New Revision: ab6a0823afc7e4cc660f0fd3bd07f791fe9e103f
URL: https://github.com/llvm/llvm-project/commit/ab6a0823afc7e4cc660f0fd3bd07f791fe9e103f
DIFF: https://github.com/llvm/llvm-project/commit/ab6a0823afc7e4cc660f0fd3bd07f791fe9e103f.diff
LOG: [LLDB] Fix out-of-bounds memory access in EmulationStateArm
Functionally broken code for reading and writing registers, likely due to typos,
and could cause out-of-bounds memory access.
Differential Revision: https://reviews.llvm.org/D131658
Added:
Modified:
lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
index da679a3e85471..4bfff9277f08b 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -51,7 +51,7 @@ bool EmulationStateARM::LoadPseudoRegistersFromFrame(StackFrame &frame) {
if (reg_ctx->ReadRegister(reg_info, reg_value)) {
uint64_t value = reg_value.GetAsUInt64();
uint32_t idx = i - dwarf_d0;
- if (i < 16) {
+ if (idx < 16) {
m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;
m_vfp_regs.s_regs[idx * 2 + 1] = (uint32_t)(value >> 32);
} else
@@ -92,7 +92,7 @@ uint64_t EmulationStateARM::ReadPseudoRegisterValue(uint32_t reg_num,
value = m_gpr[reg_num - dwarf_r0];
else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) {
uint32_t idx = reg_num - dwarf_s0;
- value = m_vfp_regs.d_regs[idx];
+ value = m_vfp_regs.s_regs[idx];
} else if ((dwarf_d0 <= reg_num) && (reg_num <= dwarf_d31)) {
uint32_t idx = reg_num - dwarf_d0;
if (idx < 16)
More information about the lldb-commits
mailing list