diff options
author | Paul Fertser <fercerpav@gmail.com> | 2014-01-06 21:36:21 +0400 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2014-01-20 13:29:01 +0000 |
commit | 245e8fff3b2bc662640b47471d516168c4bdb6e0 (patch) | |
tree | e4879b07d6acf07be591a63351ba0778e2f548c2 /src/server | |
parent | 63fa73169bd88258ef82f709e79769eacc50f793 (diff) | |
download | riscv-openocd-245e8fff3b2bc662640b47471d516168c4bdb6e0.zip riscv-openocd-245e8fff3b2bc662640b47471d516168c4bdb6e0.tar.gz riscv-openocd-245e8fff3b2bc662640b47471d516168c4bdb6e0.tar.bz2 |
gdb_server: check for invalid read memory requests
This prevents invalid free(NULL) (that crashes OpenOCD on desktop
distros).
With radare2 it's now a bit more useful, memory access works if I seek
to the correct address, can't test further as it apparently lacks thumb2
support.
Change-Id: I6ec32d09fd52dab53ba765d7f7519baa1f55d973
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1853
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/gdb_server.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 6729df3..91016e4 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1352,6 +1352,12 @@ static int gdb_read_memory_packet(struct connection *connection, len = strtoul(separator + 1, NULL, 16); + if (!len) { + LOG_WARNING("invalid read memory packet received (len == 0)"); + gdb_put_packet(connection, NULL, 0); + return ERROR_OK; + } + buffer = malloc(len); LOG_DEBUG("addr: 0x%8.8" PRIx32 ", len: 0x%8.8" PRIx32 "", addr, len); |