gdb_server: fix 'null' pointer passed as 'nonnull' parameter
The null pointer used as second parameter to gdb_put_packet() is passed as second parameter to the memcpy() in line 408 of gdb_put_packet_inner(). In this case memcpy() does not segfault because also the parameter length is zero. Nevertheless, the prototype of memcpy() requires a nonnull pointer. Fixed by passing an empty string in place of the null pointer. Issue highlighted by clang 7.0.0 with warning message: "Null pointer passed as an argument to a 'nonnull' parameter" Change-Id: Ib3dde95d76fcc5fb245ee2d6669e5535d0e0b127 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4946 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>reverse-resume-order
parent
4db695c66c
commit
334c5096eb
|
@ -1437,7 +1437,7 @@ static int gdb_read_memory_packet(struct connection *connection,
|
||||||
|
|
||||||
if (!len) {
|
if (!len) {
|
||||||
LOG_WARNING("invalid read memory packet received (len == 0)");
|
LOG_WARNING("invalid read memory packet received (len == 0)");
|
||||||
gdb_put_packet(connection, NULL, 0);
|
gdb_put_packet(connection, "", 0);
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3337,7 +3337,7 @@ static int gdb_input_inner(struct connection *connection)
|
||||||
default:
|
default:
|
||||||
/* ignore unknown packets */
|
/* ignore unknown packets */
|
||||||
LOG_DEBUG("ignoring 0x%2.2x packet", packet[0]);
|
LOG_DEBUG("ignoring 0x%2.2x packet", packet[0]);
|
||||||
gdb_put_packet(connection, NULL, 0);
|
gdb_put_packet(connection, "", 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue