Skip to contentSkip to conversation

m68knommu: Replace deprecated strcpy with strscpy in init_ucsimm

PATCH Applied Thorsten Blum 2 participants 2 messages Jan 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68knommu: Replace deprecated strcpy with strscpy in init_ucsimm

strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Replace it with the safer strscpy().

---
Compile-tested only.

---
 arch/m68k/68000/ucsimm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/68000/ucsimm.c +2 -1
index c54fde75eae8..6b84e826040f 100644
@@ -9,6 +9,7 @@
  * for more details.
  */
 #include <linux/init.h>
+#include <linux/string.h>
 #include <asm/bootstd.h>
 #include <asm/machdep.h>
 #include <asm/MC68VZ328.h>
@@ -31,7 +32,7 @@ void __init init_ucsimm(char *command, int size)
 	pr_info("uCsimm/uCdimm hwaddr %pM\n", p);
 	p = getbenv("APPEND");
 	if (p)
-		strcpy(p, command);
+		strscpy(p, command, size);
 	else
 		command[0] = 0;
 }
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
maintainer Applied
#1 lore raw

Hi Thorsten,

Quoted 6 lines · Thorsten Blum

strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Replace it with the safer strscpy().

Thanks, applied to m68knommu git tree, for-next branch.

Regards
Greg

Quoted 27 lines

---
Compile-tested only.

---
  arch/m68k/68000/ucsimm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/68000/ucsimm.c +2 -1
index c54fde75eae8..6b84e826040f 100644
@@ -9,6 +9,7 @@
   * for more details.
   */
  #include <linux/init.h>
+#include <linux/string.h>
  #include <asm/bootstd.h>
  #include <asm/machdep.h>
  #include <asm/MC68VZ328.h>
@@ -31,7 +32,7 @@ void __init init_ucsimm(char *command, int size)
  	pr_info("uCsimm/uCdimm hwaddr %pM\n", p);
  	p = getbenv("APPEND");
  	if (p)
-		strcpy(p, command);
+		strscpy(p, command, size);
  	else
  		command[0] = 0;
  }