Skip to contentSkip to conversation

m68k: atari: Use strscpy() in atari_switches_setup()

PATCH New Thorsten Blum 1 participant 1 message Nov 6 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: atari: Use strscpy() in atari_switches_setup()

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

While the current code works correctly, replace strcpy() with strscpy() to bound the copy to the size of the switches buffer.

---
 arch/m68k/atari/config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/atari/config.c +2 -1
index b82bbf93d8e7..09f4219faed6 100644
@@ -35,4 +35,5 @@
 #include <linux/usb/isp116x.h>
 #include <linux/module.h>
+#include <linux/string.h>
 #include <net/ethoc.h>
 
@@ -154,5 +155,5 @@ static int __init atari_switches_setup(char *str)
 
 	/* copy string to local array, strsep works destructively... */
-	strcpy(switches, str);
+	strscpy(switches, str);
 	atari_switches = 0;