Skip to content

Commit 5228ed2

Browse files
tobluxPaul Walmsley
authored andcommitted
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: KSPP#88 Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20251011004750.461954-1-thorsten.blum@linux.dev Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent 44aa25c commit 5228ed2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/riscv/kernel/kgdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ void kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer,
265265
{
266266
if (!strncmp(remcom_in_buffer, gdb_xfer_read_target,
267267
sizeof(gdb_xfer_read_target)))
268-
strcpy(remcom_out_buffer, riscv_gdb_stub_target_desc);
268+
strscpy(remcom_out_buffer, riscv_gdb_stub_target_desc, BUFMAX);
269269
else if (!strncmp(remcom_in_buffer, gdb_xfer_read_cpuxml,
270270
sizeof(gdb_xfer_read_cpuxml)))
271-
strcpy(remcom_out_buffer, riscv_gdb_stub_cpuxml);
271+
strscpy(remcom_out_buffer, riscv_gdb_stub_cpuxml, BUFMAX);
272272
}
273273

274274
static inline void kgdb_arch_update_addr(struct pt_regs *regs,

0 commit comments

Comments
 (0)