Skip to contentSkip to conversation

MIPS: RB532: Replace deprecated strcpy() with memcpy() and strscpy()

PATCH Applied Thorsten Blum 2 participants 2 messages Aug 19, 2025 – Aug 29, 2025 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: RB532: Replace deprecated strcpy() with memcpy() and strscpy()

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

Add the local variable 'size_t len' to keep track of the string lengths and prefer memcpy() over strscpy() when we use the string length to advance the 'cp' pointer.

No functional changes intended.

---
 arch/mips/rb532/prom.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
arch/mips/rb532/prom.c +9 -8
index b88e89ec5894..8c370eb180ef 100644
@@ -53,6 +53,7 @@ static void __init prom_setup_cmdline(void)
 	int prom_argc;
 	char **prom_argv;
 	int i;
+	size_t len;
 
 	prom_argc = fw_arg0;
 	prom_argv = (char **) fw_arg1;
@@ -82,20 +83,20 @@ static void __init prom_setup_cmdline(void)
 				mips_machtype = MACH_MIKROTIK_RB532;
 		}
 
-		strcpy(cp, prom_argv[i]);
-		cp += strlen(prom_argv[i]);
+		len = strlen(prom_argv[i]);
+		memcpy(cp, prom_argv[i], len + 1);
+		cp += len;
 	}
 	*(cp++) = ' ';
 
-	i = strlen(arcs_cmdline);
-	if (i > 0) {
+	len = strlen(arcs_cmdline);
+	if (len > 0) {
 		*(cp++) = ' ';
-		strcpy(cp, arcs_cmdline);
-		cp += strlen(arcs_cmdline);
+		memcpy(cp, arcs_cmdline, len + 1);
+		cp += len;
 	}
 	cmd_line[COMMAND_LINE_SIZE - 1] = '\0';
-
-	strcpy(arcs_cmdline, cmd_line);
+	strscpy(arcs_cmdline, cmd_line);
 }
 
 void __init prom_init(void)
Signature · 1 line
2.50.1
maintainer Applied
#1 lore raw
Quoted 57 lines · Thorsten Blum

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

Add the local variable 'size_t len' to keep track of the string lengths and prefer memcpy() over strscpy() when we use the string length to advance the 'cp' pointer.

No functional changes intended.

---
 arch/mips/rb532/prom.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
arch/mips/rb532/prom.c +9 -8
index b88e89ec5894..8c370eb180ef 100644
@@ -53,6 +53,7 @@ static void __init prom_setup_cmdline(void)
 	int prom_argc;
 	char **prom_argv;
 	int i;
+	size_t len;
 
 	prom_argc = fw_arg0;
 	prom_argv = (char **) fw_arg1;
@@ -82,20 +83,20 @@ static void __init prom_setup_cmdline(void)
 				mips_machtype = MACH_MIKROTIK_RB532;
 		}
 
-		strcpy(cp, prom_argv[i]);
-		cp += strlen(prom_argv[i]);
+		len = strlen(prom_argv[i]);
+		memcpy(cp, prom_argv[i], len + 1);
+		cp += len;
 	}
 	*(cp++) = ' ';
 
-	i = strlen(arcs_cmdline);
-	if (i > 0) {
+	len = strlen(arcs_cmdline);
+	if (len > 0) {
 		*(cp++) = ' ';
-		strcpy(cp, arcs_cmdline);
-		cp += strlen(arcs_cmdline);
+		memcpy(cp, arcs_cmdline, len + 1);
+		cp += len;
 	}
 	cmd_line[COMMAND_LINE_SIZE - 1] = '\0';
-
-	strcpy(arcs_cmdline, cmd_line);
+	strscpy(arcs_cmdline, cmd_line);
 }
 
 void __init prom_init(void)
Signature · 1 line
2.50.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]