GDB: Range check register in remoteReadRegister and remoteWriteRegister

This commit is contained in:
Martin Sundhaug 2016-09-07 18:29:57 -04:00
parent 1eb768578b
commit 9ad1506ed7
1 changed files with 11 additions and 0 deletions

View File

@ -3945,6 +3945,11 @@ void remoteReadRegister(char* p)
{
int r;
sscanf(p, "%x", &r);
if(r < 0 || r > 15)
{
remotePutPacket("E 00");
return;
}
char buffer[1024];
char* s = buffer;
uint32_t v = reg[r].I;
@ -3997,6 +4002,12 @@ void remoteWriteRegister(char* p)
sscanf(p, "%x=", &r);
if(r < 0 || r > 15)
{
remotePutPacket("E 00");
return;
}
p = strchr(p, '=');
p++;