Skip to contentSkip to conversation

Fix off-by-two in arcs_cmdline buffer size check

PATCH Applied Thomas Jarosch 2 participants 2 messages Oct 29, 2011 – Nov 2, 2011 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix off-by-two in arcs_cmdline buffer size check

Cause is a misplaced bracket.

The code

    strlen(buf+1)

will be two bytes less than

    strlen(buf)+1

The +1 is in this code to reserve space for an additional space character.

---
 arch/mips/pmc-sierra/yosemite/prom.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/mips/pmc-sierra/yosemite/prom.c +1 -1
index cf4c868..a6d5eb3 100644
@@ -102,7 +102,7 @@ void __init prom_init(void)
 
 	/* Get the boot parameters */
 	for (i = 1; i < argc; i++) {
-		if (strlen(arcs_cmdline) + strlen(arg[i] + 1) >=
+		if (strlen(arcs_cmdline) + strlen(arg[i]) + 1 >=
 		    sizeof(arcs_cmdline))
 			break;
 
Signature · 1 line
1.7.6.4
Applied
#1 lore raw
Quoted 11 lines · Thomas Jarosch

Cause is a misplaced bracket.

The code

    strlen(buf+1)

will be two bytes less than

    strlen(buf)+1

The +1 is in this code to reserve space for an additional space character.

Thanks, applied.

The same buggy code just formatted slightly differently also exists in Emma. I added the Emma fix to the patch and applied it.

Thanks!

Ralf