[PATCH] Fix off-by-two in arcs_cmdline buffer size check

Subsystems: mips, the rest

STALE5466d

2 messages, 2 authors, 2011-11-02 · open the first message on its own page

[PATCH] Fix off-by-two in arcs_cmdline buffer size check

From: Thomas Jarosch <hidden>
Date: 2011-10-29 13:46:00

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.

Signed-off-by: Thomas Jarosch <redacted>
---
 arch/mips/pmc-sierra/yosemite/prom.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/mips/pmc-sierra/yosemite/prom.c b/arch/mips/pmc-sierra/yosemite/prom.c
index cf4c868..a6d5eb3 100644
--- a/arch/mips/pmc-sierra/yosemite/prom.c
+++ b/arch/mips/pmc-sierra/yosemite/prom.c
@@ -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;
 
-- 
1.7.6.4

Re: [PATCH] Fix off-by-two in arcs_cmdline buffer size check

From: Ralf Baechle <hidden>
Date: 2011-11-02 13:21:34

On Sat, Oct 29, 2011 at 03:45:56PM +0200, Thomas Jarosch wrote:
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help