From: Daniel Kirschten Date: Mon, 14 Oct 2019 21:15:38 +0000 (+0200) Subject: Fixed bounds checking and address length in MainMemoryBlockExtension X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=1361a615968f7aa4d686d2e55176c02475612cd3;p=Mograsim.git Fixed bounds checking and address length in MainMemoryBlockExtension --- 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