Skip to content

Commit

Permalink
gdb_server: check for invalid read memory requests
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-on: http://openocd.zylin.com/1853
Tested-by: jenkins
Reviewed-by: Spencer Oliver <[email protected]>
  • Loading branch information
paulfertser authored and ntfreak committed Jan 20, 2014
1 parent 63fa731 commit 245e8ff
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/server/gdb_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 245e8ff

Please sign in to comment.