[PATCH 3/8] MIPS: lemote-2f: bound machtype command-line append
From: Pengpeng Hou
Date: Sat Apr 04 2026 - 22:32:28 EST
mach_prom_init_machtype() appends the synthesized machtype argument to
the fixed arcs_cmdline buffer with a chain of unchecked strcat() calls.
If the PROM command line is already near full, the extra machtype text
can run past the end of the buffer.
Switch the append steps to bounded concatenation.
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
arch/mips/loongson2ef/lemote-2f/machtype.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/mips/loongson2ef/lemote-2f/machtype.c b/arch/mips/loongson2ef/lemote-2f/machtype.c
index 9462a3ab57be..359fe7f826b8 100644
--- a/arch/mips/loongson2ef/lemote-2f/machtype.c
+++ b/arch/mips/loongson2ef/lemote-2f/machtype.c
@@ -34,8 +34,10 @@ void __init mach_prom_init_machtype(void)
else
mips_machtype = MACH_LEMOTE_NAS;
- strcat(arcs_cmdline, " machtype=");
- strcat(arcs_cmdline, get_system_type());
- strcat(arcs_cmdline, " ");
- }
+ strlcat(arcs_cmdline, " machtype=",
+ COMMAND_LINE_SIZE);
+ strlcat(arcs_cmdline, get_system_type(),
+ COMMAND_LINE_SIZE);
+ strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
+ }
}
--
2.50.1 (Apple Git-155)