Skip to contentSkip to conversation

m68k: mm: Replace strcpy() with strscpy() in hardware_proc_show()

PATCH In review Thorsten Blum 4 participants 5 messages Apr 21, 2025 – Apr 22, 2025 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: mm: Replace strcpy() with strscpy() in hardware_proc_show()

strcpy() is deprecated; use strscpy() instead.

---
 arch/m68k/kernel/setup_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/kernel/setup_mm.c +1 -1
index 0fba32552836..c7e8de0d34bb 100644
@@ -484,7 +484,7 @@ static int hardware_proc_show(struct seq_file *m, void *v)
 	if (mach_get_model)
 		mach_get_model(model);
 	else
-		strcpy(model, "Unknown m68k");
+		strscpy(model, "Unknown m68k");
 
 	seq_printf(m, "Model:\t\t%s\n", model);
 	for (mem = 0, i = 0; i < m68k_num_memory; i++)
Signature · 1 line
2.49.0
#1 lore raw

Hi Thorsten,

Quoted 14 lines · Thorsten Blum

strcpy() is deprecated; use strscpy() instead.

---
  arch/m68k/kernel/setup_mm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/kernel/setup_mm.c +0 -0
index 0fba32552836..c7e8de0d34bb 100644

arch/m68k/kernel/setup_mm.c static int hardware_proc_show(struct seq_file *m, void *v) · line 490

Quoted 8 lines
arch/m68k/kernel/setup_mm.c +1 -1
@@ -484,7 +484,7 @@ static int hardware_proc_show(struct seq_file *m, void *v)
  	if (mach_get_model)
  		mach_get_model(model);
  	else
-		strcpy(model, "Unknown m68k");
+		strscpy(model, "Unknown m68k");
 
  	seq_printf(m, "Model:\t\t%s\n", model);
  	for (mem = 0, i = 0; i < m68k_num_memory; i++)

As we are not using the return value, I think it is a safe replacement.

#3 lore raw

Hi Michael,

Quoted 10 lines · Michael Schmitz

Jean-Michel,

Am 22.04.2025 um 01:02 schrieb Jean-Michel Hautbois:

Quoted 3 lines

As we are not using the return value, I think it is a safe replacement.

Would not 'Reviewed-by' be more appropriate here?

Oh my, indeed, not enough sleeping lately :-/ !

JM

maintainer Reviewed-by
#4 lore raw
In reply to Jean-Michel Hautbois

Hi Jean-Michel,

Quoted 21 lines · Jean-Michel Hautbois
Quoted 20 lines · Thorsten Blum

strcpy() is deprecated; use strscpy() instead.

---
  arch/m68k/kernel/setup_mm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/kernel/setup_mm.c +1 -1
index 0fba32552836..c7e8de0d34bb 100644
@@ -484,7 +484,7 @@ static int hardware_proc_show(struct seq_file *m, void *v)
      if (mach_get_model)
              mach_get_model(model);
      else
-             strcpy(model, "Unknown m68k");
+             strscpy(model, "Unknown m68k");
 
Quoted 4 lines

arch/m68k/kernel/setup_mm.c static int hardware_proc_show(struct seq_file *m, void *v) · line 490

Quoted 2 lines
arch/m68k/kernel/setup_mm.c +0 -0
      seq_printf(m, "Model:\t\t%s\n", model);
      for (mem = 0, i = 0; i < m68k_num_memory; i++)

As we are not using the return value, I think it is a safe replacement.

strcpy() and strscpy() not only differ in return value: the (optional) third parameter of strscpy() specifies the destination buffer size. When not passed, the size is taken from the actual destination buffer.

i.e. will queue in the m68k tree for v6.16.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds