linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix off-by-two in arcs_cmdline buffer size check
@ 2011-10-29 13:45 Thomas Jarosch
  2011-11-02 13:21 ` Ralf Baechle
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Jarosch @ 2011-10-29 13:45 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, linux-kernel

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix off-by-two in arcs_cmdline buffer size check
  2011-10-29 13:45 [PATCH] Fix off-by-two in arcs_cmdline buffer size check Thomas Jarosch
@ 2011-11-02 13:21 ` Ralf Baechle
  0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2011-11-02 13:21 UTC (permalink / raw)
  To: Thomas Jarosch; +Cc: linux-mips, linux-kernel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-02 13:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-29 13:45 [PATCH] Fix off-by-two in arcs_cmdline buffer size check Thomas Jarosch
2011-11-02 13:21 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).