From ebdd30e92cc37d5a4120d399f8728615c313f917 Mon Sep 17 00:00:00 2001 From: Martijn Plak Date: Tue, 23 Jan 2024 08:41:53 +0100 Subject: [PATCH] readmem (ARM): boundary check against end of addressable space --- armsrc/appmain.c | 3 +++ bootrom/bootrom.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 7032983f7..71febb7e2 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -2393,6 +2393,9 @@ static void PacketReceived(PacketCommandNG *packet) { } else { // Allow reading from any memory address and length in special 'raw' mode. base = NULL; + // Boundary check against end of addressable space. + if (offset > 0) + count=MIN(count, -offset); } if (isok) { diff --git a/bootrom/bootrom.c b/bootrom/bootrom.c index 632fe88d1..9349ffd7c 100644 --- a/bootrom/bootrom.c +++ b/bootrom/bootrom.c @@ -186,6 +186,9 @@ static void UsbPacketReceived(uint8_t *packet) { } else { // Allow reading from any memory address and length in special 'raw' mode. base = NULL; + // Boundary check against end of addressable space. + if (offset > 0) + count=MIN(count, -offset); } if (isok) {