From bfa675cb9da92b0baa8c1fdf94d06f9eb0d848f8 Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Mon, 27 Dec 2021 16:55:43 -0500 Subject: [PATCH] GDB Stub: validate the address exists before reading/writting to it --- Source/Core/Core/PowerPC/GDBStub.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/PowerPC/GDBStub.cpp b/Source/Core/Core/PowerPC/GDBStub.cpp index 45896ec4ab..80a180ca1f 100644 --- a/Source/Core/Core/PowerPC/GDBStub.cpp +++ b/Source/Core/Core/PowerPC/GDBStub.cpp @@ -536,9 +536,10 @@ static void ReadMemory() if (len * 2 > sizeof reply) SendReply("E01"); + + if (!PowerPC::HostIsRAMAddress(addr)) + return SendReply("E00"); u8* data = Memory::GetPointer(addr); - if (!data) - return SendReply("E0"); Mem2hex(reply, data, len); reply[len * 2] = '\0'; SendReply((char*)reply); @@ -560,9 +561,9 @@ static void WriteMemory() len = (len << 4) | Hex2char(s_cmd_bfr[i++]); INFO_LOG_FMT(GDB_STUB, "gdb: write memory: {:08x} bytes to {:08x}", len, addr); - u8* dst = Memory::GetPointer(addr); - if (!dst) + if (!PowerPC::HostIsRAMAddress(addr)) return SendReply("E00"); + u8* dst = Memory::GetPointer(addr); Hex2mem(dst, s_cmd_bfr + i + 1, len); SendReply("OK"); }