Skip to contentSkip to conversation

MIPS: Cobalt use strlcat() for the command line arguments

PATCH In review Yoichi Yuasa 2 participants 2 messages Dec 24, 2009 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: Cobalt use strlcat() for the command line arguments

Tested with CoLo v1.22

---
 arch/mips/cobalt/setup.c |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)
arch/mips/cobalt/setup.c +8 -16
index b516442..ec3b2c4 100644
@@ -97,26 +97,18 @@ void __init plat_mem_setup(void)
 
 void __init prom_init(void)
 {
-	int narg, indx, posn, nchr;
 	unsigned long memsz;
+	int argc, i;
 	char **argv;
 
 	memsz = fw_arg0 & 0x7fff0000;
-	narg = fw_arg0 & 0x0000ffff;
-
-	if (narg) {
-		arcs_cmdline[0] = '\0';
-		argv = (char **) fw_arg1;
-		posn = 0;
-		for (indx = 1; indx < narg; ++indx) {
-			nchr = strlen(argv[indx]);
-			if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline))
-				break;
-			if (posn)
-				arcs_cmdline[posn++] = ' ';
-			strcpy(arcs_cmdline + posn, argv[indx]);
-			posn += nchr;
-		}
+	argc = fw_arg0 & 0x0000ffff;
+	argv = (char **)fw_arg1;
+
+	for (i = 1; i < argc; i++) {
+		strlcat(arcs_cmdline, argv[i], COMMAND_LINE_SIZE);
+		if (i < (argc - 1))
+			strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
 	}
 
 	add_memory_region(0x0, memsz, BOOT_MEM_RAM);
Signature · 1 line
1.6.5.7
#1 lore raw

On Thu, Dec 24, 2009 at 05:06:34PM +0900, Yoichi Yuasa wrote:

Thanks Yoichi-San! Also applied.

Ralf