Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2537: Fix off-by-one error in gdb default 64-bit memory region split

Danb1c9e0360bfc
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetProcessMemory.java b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetProcessMemory.java
index 4e08f16528..48694e035c 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetProcessMemory.java
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetProcessMemory.java
@@ -81,12 +81,14 @@ public class GdbModelTargetProcessMemory
}
if (size == 8) {
// TODO: This split shouldn't be necessary.
- BigInteger split = BigInteger.valueOf(Long.MAX_VALUE);
- GdbMemoryMapping lowMapping = new GdbMemoryMapping(start, split,
- split.subtract(start), BigInteger.ZERO, "rwx", "defaultLow");
- GdbMemoryMapping highMapping = new GdbMemoryMapping(split, end,
- end.subtract(split), BigInteger.ZERO, "rwx", "defaultHigh");
- return Map.of(start, lowMapping, split, highMapping);
+ BigInteger lowEnd = BigInteger.valueOf(Long.MAX_VALUE);
+ BigInteger highStart = lowEnd.add(BigInteger.ONE);
+
+ GdbMemoryMapping lowMapping = new GdbMemoryMapping(start, lowEnd,
+ lowEnd.subtract(start), BigInteger.ZERO, "rwx", "defaultLow");
+ GdbMemoryMapping highMapping = new GdbMemoryMapping(highStart, end,
+ end.subtract(highStart), BigInteger.ZERO, "rwx", "defaultHigh");
+ return Map.of(start, lowMapping, highStart, highMapping);
}
throw new GdbCommandError("Unexpected address size: " + size);
});