Skip to content

Commit 05c81ed

Browse files
tobluxdaniel-thompson
authored andcommitted
kernel: debug: gdbstub: Replace deprecated strcpy() with strscpy()
strcpy() is deprecated; use strscpy() instead. Link: KSPP#88 Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
1 parent 76eeb9b commit 05c81ed

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

kernel/debug/gdbstub.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/kgdb.h>
3131
#include <linux/kdb.h>
3232
#include <linux/serial_core.h>
33+
#include <linux/string.h>
3334
#include <linux/reboot.h>
3435
#include <linux/uaccess.h>
3536
#include <asm/cacheflush.h>
@@ -547,7 +548,7 @@ static void gdb_cmd_setregs(struct kgdb_state *ks)
547548
error_packet(remcom_out_buffer, -EINVAL);
548549
} else {
549550
gdb_regs_to_pt_regs(gdb_regs, ks->linux_regs);
550-
strcpy(remcom_out_buffer, "OK");
551+
strscpy(remcom_out_buffer, "OK");
551552
}
552553
}
553554

@@ -577,7 +578,7 @@ static void gdb_cmd_memwrite(struct kgdb_state *ks)
577578
if (err)
578579
error_packet(remcom_out_buffer, err);
579580
else
580-
strcpy(remcom_out_buffer, "OK");
581+
strscpy(remcom_out_buffer, "OK");
581582
}
582583

583584
#if DBG_MAX_REG_NUM > 0
@@ -630,7 +631,7 @@ static void gdb_cmd_reg_set(struct kgdb_state *ks)
630631
i = i / 2;
631632
kgdb_hex2mem(ptr, (char *)gdb_regs, i);
632633
dbg_set_reg(regnum, gdb_regs, ks->linux_regs);
633-
strcpy(remcom_out_buffer, "OK");
634+
strscpy(remcom_out_buffer, "OK");
634635
}
635636
#endif /* DBG_MAX_REG_NUM > 0 */
636637

@@ -642,7 +643,7 @@ static void gdb_cmd_binwrite(struct kgdb_state *ks)
642643
if (err)
643644
error_packet(remcom_out_buffer, err);
644645
else
645-
strcpy(remcom_out_buffer, "OK");
646+
strscpy(remcom_out_buffer, "OK");
646647
}
647648

648649
/* Handle the 'D' or 'k', detach or kill packets */
@@ -656,7 +657,7 @@ static void gdb_cmd_detachkill(struct kgdb_state *ks)
656657
if (error < 0) {
657658
error_packet(remcom_out_buffer, error);
658659
} else {
659-
strcpy(remcom_out_buffer, "OK");
660+
strscpy(remcom_out_buffer, "OK");
660661
kgdb_connected = 0;
661662
}
662663
put_packet(remcom_out_buffer);
@@ -676,7 +677,7 @@ static int gdb_cmd_reboot(struct kgdb_state *ks)
676677
/* For now, only honor R0 */
677678
if (strcmp(remcom_in_buffer, "R0") == 0) {
678679
printk(KERN_CRIT "Executing emergency reboot\n");
679-
strcpy(remcom_out_buffer, "OK");
680+
strscpy(remcom_out_buffer, "OK");
680681
put_packet(remcom_out_buffer);
681682

682683
/*
@@ -739,7 +740,7 @@ static void gdb_cmd_query(struct kgdb_state *ks)
739740

740741
case 'C':
741742
/* Current thread id */
742-
strcpy(remcom_out_buffer, "QC");
743+
strscpy(remcom_out_buffer, "QC");
743744
ks->threadid = shadow_pid(current->pid);
744745
int_to_threadref(thref, ks->threadid);
745746
pack_threadid(remcom_out_buffer + 2, thref);
@@ -773,7 +774,7 @@ static void gdb_cmd_query(struct kgdb_state *ks)
773774
int len = strlen(remcom_in_buffer + 6);
774775

775776
if ((len % 2) != 0) {
776-
strcpy(remcom_out_buffer, "E01");
777+
strscpy(remcom_out_buffer, "E01");
777778
break;
778779
}
779780
kgdb_hex2mem(remcom_in_buffer + 6,
@@ -785,14 +786,14 @@ static void gdb_cmd_query(struct kgdb_state *ks)
785786
kdb_parse(remcom_out_buffer);
786787
kdb_common_deinit_state();
787788

788-
strcpy(remcom_out_buffer, "OK");
789+
strscpy(remcom_out_buffer, "OK");
789790
}
790791
break;
791792
#endif
792793
#ifdef CONFIG_HAVE_ARCH_KGDB_QXFER_PKT
793794
case 'S':
794795
if (!strncmp(remcom_in_buffer, "qSupported:", 11))
795-
strcpy(remcom_out_buffer, kgdb_arch_gdb_stub_feature);
796+
strscpy(remcom_out_buffer, kgdb_arch_gdb_stub_feature);
796797
break;
797798
case 'X':
798799
if (!strncmp(remcom_in_buffer, "qXfer:", 6))
@@ -822,7 +823,7 @@ static void gdb_cmd_task(struct kgdb_state *ks)
822823
}
823824
kgdb_usethread = thread;
824825
ks->kgdb_usethreadid = ks->threadid;
825-
strcpy(remcom_out_buffer, "OK");
826+
strscpy(remcom_out_buffer, "OK");
826827
break;
827828
case 'c':
828829
ptr = &remcom_in_buffer[2];
@@ -837,7 +838,7 @@ static void gdb_cmd_task(struct kgdb_state *ks)
837838
}
838839
kgdb_contthread = thread;
839840
}
840-
strcpy(remcom_out_buffer, "OK");
841+
strscpy(remcom_out_buffer, "OK");
841842
break;
842843
}
843844
}
@@ -851,7 +852,7 @@ static void gdb_cmd_thread(struct kgdb_state *ks)
851852
kgdb_hex2long(&ptr, &ks->threadid);
852853
thread = getthread(ks->linux_regs, ks->threadid);
853854
if (thread)
854-
strcpy(remcom_out_buffer, "OK");
855+
strscpy(remcom_out_buffer, "OK");
855856
else
856857
error_packet(remcom_out_buffer, -EINVAL);
857858
}
@@ -913,7 +914,7 @@ static void gdb_cmd_break(struct kgdb_state *ks)
913914
(int) length, *bpt_type - '0');
914915

915916
if (error == 0)
916-
strcpy(remcom_out_buffer, "OK");
917+
strscpy(remcom_out_buffer, "OK");
917918
else
918919
error_packet(remcom_out_buffer, error);
919920
}

0 commit comments

Comments
 (0)