Fix stack overflow in remoteMemoryRead

When doing a remote memory read the debugger can ask for any size.
The buffer being allocated however was only 1024 bytes long and the
code in remoteMemoryRead also attempts to write a zero byte at the
end of the array. This code will now take the count of bytes the debugger
is trying to read and allocates a buffer that is count * 2 + 1 large. This is large
enough to hold the $02x formatted hex byte for each byte as well as the zero
byte written at the end.
This commit is contained in:
Scott Knight 2018-11-27 17:32:58 -05:00
parent 4f28e84632
commit dd2a1d9b51
No known key found for this signature in database
GPG Key ID: 8D2E42E6C5F4A267
1 changed files with 1 additions and 1 deletions

View File

@ -3684,7 +3684,7 @@ void remoteMemoryRead(char* p)
sscanf(p, "%x,%x:", &address, &count);
// monprintf("Memory read for %08x %d\n", address, count);
char buffer[1024];
char buffer[(count*2)+1];
char* s = buffer;
for (int i = 0; i < count; i++) {