Re: [2.6 patch] fix array over-run in efi.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>

--- 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




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux