public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darren Jenkins\\" <darrenrjenkins@gmail.com>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: Adrian Bunk <bunk@stusta.de>, Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [2.6 patch] fix array over-run in efi.c
Date: Sun, 26 Mar 2006 12:18:10 +1000	[thread overview]
Message-ID: <1143339491.8088.6.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.61.0603251941111.29793@yvahk01.tjqt.qr>

On Sat, 2006-03-25 at 19:41 +0100, Jan Engelhardt wrote:
> >-		for (i = 0; i < sizeof(vendor) && *c16; ++i)
> >+		for (i = 0; i < (sizeof(vendor) - 1) && *c16; ++i)
> 
>                 for (i = 0; i <  sizeof(vendor) - 1  && *c16; ++i)
> Should suffice.
> 
> 
> Jan Engelhardt


OK since it is preferred without the brackets, here it is again.



Coverity found an over-run @ line 364 of efi.c

This is due to the loop checking the size correctly, then adding a '\0'
after possibly hitting the end of the array.

The patch below just ensures the loop exits with one space left in the
array.

Compile tested.

Signed-off-by: Darren Jenkins <darrenrjenkins@gmail.com>

--- linux-2.6.16-git8/arch/i386/kernel/efi.c.orig	2006-03-26 12:06:47.000000000 +1000
+++ linux-2.6.16-git8/arch/i386/kernel/efi.c	2006-03-26 12:08:34.000000000 +1000
@@ -361,7 +361,7 @@ void __init efi_init(void)
 	 */
 	c16 = (efi_char16_t *) boot_ioremap(efi.systab->fw_vendor, 2);
 	if (c16) {
-		for (i = 0; i < sizeof(vendor) && *c16; ++i)
+		for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i)
 			vendor[i] = *c16++;
 		vendor[i] = '\0';
 	} else





      parent reply	other threads:[~2006-03-26  2:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-25 11:58 [2.6 patch] fix array over-run in efi.c Adrian Bunk
2006-03-25 18:41 ` Jan Engelhardt
2006-03-25 21:15   ` Adrian Bunk
2006-03-26  2:18   ` Darren Jenkins\ [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1143339491.8088.6.camel@localhost.localdomain \
    --to=darrenrjenkins@gmail.com \
    --cc=akpm@osdl.org \
    --cc=bunk@stusta.de \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox