linux-mips
[Top] [All Lists]

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

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH] Fix off-by-two in arcs_cmdline buffer size check
From: Thomas Jarosch <thomas.jarosch@intra2net.com>
Date: Sat, 29 Oct 2011 15:45:56 +0200
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110927 Thunderbird/7.0
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 <thomas.jarosch@intra2net.com>
---
 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


<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] Fix off-by-two in arcs_cmdline buffer size check, Thomas Jarosch <=