Merge pull request #10308 from aldelaro5/gdb-stub-fix-unkown-pointer
GDB Stub: validate the address exists before reading/writting to it
This commit is contained in:
commit
27a2df410a
|
@ -788,9 +788,10 @@ static void ReadMemory()
|
||||||
|
|
||||||
if (len * 2 > sizeof reply)
|
if (len * 2 > sizeof reply)
|
||||||
SendReply("E01");
|
SendReply("E01");
|
||||||
|
|
||||||
|
if (!PowerPC::HostIsRAMAddress(addr))
|
||||||
|
return SendReply("E00");
|
||||||
u8* data = Memory::GetPointer(addr);
|
u8* data = Memory::GetPointer(addr);
|
||||||
if (!data)
|
|
||||||
return SendReply("E0");
|
|
||||||
Mem2hex(reply, data, len);
|
Mem2hex(reply, data, len);
|
||||||
reply[len * 2] = '\0';
|
reply[len * 2] = '\0';
|
||||||
SendReply((char*)reply);
|
SendReply((char*)reply);
|
||||||
|
@ -812,9 +813,9 @@ static void WriteMemory()
|
||||||
len = (len << 4) | Hex2char(s_cmd_bfr[i++]);
|
len = (len << 4) | Hex2char(s_cmd_bfr[i++]);
|
||||||
INFO_LOG_FMT(GDB_STUB, "gdb: write memory: {:08x} bytes to {:08x}", len, addr);
|
INFO_LOG_FMT(GDB_STUB, "gdb: write memory: {:08x} bytes to {:08x}", len, addr);
|
||||||
|
|
||||||
u8* dst = Memory::GetPointer(addr);
|
if (!PowerPC::HostIsRAMAddress(addr))
|
||||||
if (!dst)
|
|
||||||
return SendReply("E00");
|
return SendReply("E00");
|
||||||
|
u8* dst = Memory::GetPointer(addr);
|
||||||
Hex2mem(dst, s_cmd_bfr + i + 1, len);
|
Hex2mem(dst, s_cmd_bfr + i + 1, len);
|
||||||
SendReply("OK");
|
SendReply("OK");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue