From 1361a615968f7aa4d686d2e55176c02475612cd3 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Mon, 14 Oct 2019 23:15:38 +0200 Subject: [PATCH] Fixed bounds checking and address length in MainMemoryBlockExtension --- .../net/mograsim/plugin/launch/MainMemoryBlockExtension.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MainMemoryBlockExtension.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MainMemoryBlockExtension.java index 7e517ca5..2bec7023 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MainMemoryBlockExtension.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MainMemoryBlockExtension.java @@ -72,7 +72,7 @@ public class MainMemoryBlockExtension extends PlatformObject implements IMemoryB if (baseAddrWords.compareTo(minAddrWords) < 0 || baseAddrWords.compareTo(maxAddrWords) > 0) throwDebugException("Base address out of range"); - if (baseAddrWords.add(lengthWords).compareTo(maxAddrWords) > 0) + if (baseAddrWords.add(lengthWords).subtract(BigInteger.ONE).compareTo(maxAddrWords) > 0) throwDebugException("End address out of range"); this.clients = new HashSet<>(); @@ -195,7 +195,7 @@ public class MainMemoryBlockExtension extends PlatformObject implements IMemoryB @Override public int getAddressSize() throws DebugException { - return Long.BYTES; + return getBigLength().bitLength() / 8; } @Override -- 2.17.1