Skip to contentSkip to conversation

riscv: KGDB: Replace deprecated strcpy in kgdb_arch_handle_qxfer_pkt

PATCH In review Thorsten Blum 2 participants 2 messages Oct 11, 2025 – Oct 28, 2025 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 arch/riscv/kernel/kgdb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/kgdb.c +2 -2
index 9f3db3503dab..15fec5d1e6de 100644
@@ -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,
Signature · 1 line
2.51.0