]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
riscv: KGDB: Replace deprecated strcpy in kgdb_arch_handle_qxfer_pkt
authorThorsten Blum <thorsten.blum@linux.dev>
Sat, 11 Oct 2025 00:47:47 +0000 (02:47 +0200)
committerPaul Walmsley <pjw@kernel.org>
Tue, 28 Oct 2025 05:30:01 +0000 (23:30 -0600)
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: 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>
arch/riscv/kernel/kgdb.c

index 9f3db3503dabd6fa9c0cc5e32403629f41dc2cbf..15fec5d1e6decfd7d6a6e3031579905ea53da692 100644 (file)
@@ -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,