Commit 5228ed2c authored by Thorsten Blum's avatar Thorsten Blum Committed by Paul Walmsley
Browse files

riscv: KGDB: Replace deprecated strcpy in kgdb_arch_handle_qxfer_pkt

strcpy() is deprecated because it can cause a buffer overflow when the
sizes of the source and the destination are not known at compile time.
Use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88


Signed-off-by: default avatarThorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20251011004750.461954-1-thorsten.blum@linux.dev


Signed-off-by: default avatarPaul Walmsley <pjw@kernel.org>
parent 44aa25c0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -265,10 +265,10 @@ void kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer,
{
	if (!strncmp(remcom_in_buffer, gdb_xfer_read_target,
		     sizeof(gdb_xfer_read_target)))
		strcpy(remcom_out_buffer, riscv_gdb_stub_target_desc);
		strscpy(remcom_out_buffer, riscv_gdb_stub_target_desc, BUFMAX);
	else if (!strncmp(remcom_in_buffer, gdb_xfer_read_cpuxml,
			  sizeof(gdb_xfer_read_cpuxml)))
		strcpy(remcom_out_buffer, riscv_gdb_stub_cpuxml);
		strscpy(remcom_out_buffer, riscv_gdb_stub_cpuxml, BUFMAX);
}

static inline void kgdb_arch_update_addr(struct pt_regs *regs,