Skip to content

Commit 51f96bf

Browse files
tobluxtsbogend
authored andcommitted
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. Link: KSPP#88 Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent b7c1ee2 commit 51f96bf

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

arch/mips/rb532/prom.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static void __init prom_setup_cmdline(void)
5353
int prom_argc;
5454
char **prom_argv;
5555
int i;
56+
size_t len;
5657

5758
prom_argc = fw_arg0;
5859
prom_argv = (char **) fw_arg1;
@@ -82,20 +83,20 @@ static void __init prom_setup_cmdline(void)
8283
mips_machtype = MACH_MIKROTIK_RB532;
8384
}
8485

85-
strcpy(cp, prom_argv[i]);
86-
cp += strlen(prom_argv[i]);
86+
len = strlen(prom_argv[i]);
87+
memcpy(cp, prom_argv[i], len + 1);
88+
cp += len;
8789
}
8890
*(cp++) = ' ';
8991

90-
i = strlen(arcs_cmdline);
91-
if (i > 0) {
92+
len = strlen(arcs_cmdline);
93+
if (len > 0) {
9294
*(cp++) = ' ';
93-
strcpy(cp, arcs_cmdline);
94-
cp += strlen(arcs_cmdline);
95+
memcpy(cp, arcs_cmdline, len + 1);
96+
cp += len;
9597
}
9698
cmd_line[COMMAND_LINE_SIZE - 1] = '\0';
97-
98-
strcpy(arcs_cmdline, cmd_line);
99+
strscpy(arcs_cmdline, cmd_line);
99100
}
100101

101102
void __init prom_init(void)

0 commit comments

Comments
 (0)