Fixed bounds checking and address length in MainMemoryBlockExtension
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 14 Oct 2019 21:15:38 +0000 (23:15 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 14 Oct 2019 21:16:14 +0000 (23:16 +0200)
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/launch/MainMemoryBlockExtension.java

index 7e517ca..2bec702 100644 (file)
@@ -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