* [U-Boot] [PATCH] vfat: Fix mkcksum argument sizes
@ 2013-01-11 13:35 Marek Vasut
2013-01-28 15:12 ` Michal Simek
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Marek Vasut @ 2013-01-11 13:35 UTC (permalink / raw)
To: u-boot
In case a function argument is known/fixed size array in C, the argument is
still decoyed as pointer instead ( T f(U n[k]) ~= T fn(U *n) ) and therefore
calling sizeof on the function argument will result in the size of the pointer,
not the size of the array.
The VFAT code contains such a bug, this patch fixes it.
Reported-by: Aaron Williams <Aaron.Williams@cavium.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <tom.rini@gmail.com>
Cc: Aaron Williams <Aaron.Williams@cavium.com>
---
fs/fat/fat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 393c378..25d3318 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -569,9 +569,9 @@ static __u8 mkcksum(const char name[8], const char ext[3])
__u8 ret = 0;
- for (i = 0; i < sizeof(name); i++)
+ for (i = 0; i < 8; i++)
ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + name[i];
- for (i = 0; i < sizeof(ext); i++)
+ for (i = 0; i < 3; i++)
ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + ext[i];
return ret;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] vfat: Fix mkcksum argument sizes
2013-01-11 13:35 [U-Boot] [PATCH] vfat: Fix mkcksum argument sizes Marek Vasut
@ 2013-01-28 15:12 ` Michal Simek
2013-01-31 15:34 ` Joe Hershberger
2013-01-31 19:44 ` [U-Boot] " Tom Rini
2 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2013-01-28 15:12 UTC (permalink / raw)
To: u-boot
2013/1/11 Marek Vasut <marex@denx.de>:
> In case a function argument is known/fixed size array in C, the argument is
> still decoyed as pointer instead ( T f(U n[k]) ~= T fn(U *n) ) and therefore
> calling sizeof on the function argument will result in the size of the pointer,
> not the size of the array.
>
> The VFAT code contains such a bug, this patch fixes it.
>
> Reported-by: Aaron Williams <Aaron.Williams@cavium.com>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <tom.rini@gmail.com>
> Cc: Aaron Williams <Aaron.Williams@cavium.com>
> ---
> fs/fat/fat.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Tested-by: Michal Simek <michal.simek@xilinx.com>
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] vfat: Fix mkcksum argument sizes
2013-01-11 13:35 [U-Boot] [PATCH] vfat: Fix mkcksum argument sizes Marek Vasut
2013-01-28 15:12 ` Michal Simek
@ 2013-01-31 15:34 ` Joe Hershberger
2013-01-31 19:44 ` [U-Boot] " Tom Rini
2 siblings, 0 replies; 5+ messages in thread
From: Joe Hershberger @ 2013-01-31 15:34 UTC (permalink / raw)
To: u-boot
On Fri, Jan 11, 2013 at 7:35 AM, Marek Vasut <marex@denx.de> wrote:
> In case a function argument is known/fixed size array in C, the argument is
> still decoyed as pointer instead ( T f(U n[k]) ~= T fn(U *n) ) and therefore
> calling sizeof on the function argument will result in the size of the pointer,
> not the size of the array.
>
> The VFAT code contains such a bug, this patch fixes it.
>
> Reported-by: Aaron Williams <Aaron.Williams@cavium.com>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <tom.rini@gmail.com>
> Cc: Aaron Williams <Aaron.Williams@cavium.com>
> ---
> fs/fat/fat.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> index 393c378..25d3318 100644
> --- a/fs/fat/fat.c
> +++ b/fs/fat/fat.c
> @@ -569,9 +569,9 @@ static __u8 mkcksum(const char name[8], const char ext[3])
>
> __u8 ret = 0;
>
> - for (i = 0; i < sizeof(name); i++)
> + for (i = 0; i < 8; i++)
> ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + name[i];
> - for (i = 0; i < sizeof(ext); i++)
> + for (i = 0; i < 3; i++)
> ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + ext[i];
>
> return ret;
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] vfat: Fix mkcksum argument sizes
2013-01-11 13:35 [U-Boot] [PATCH] vfat: Fix mkcksum argument sizes Marek Vasut
2013-01-28 15:12 ` Michal Simek
2013-01-31 15:34 ` Joe Hershberger
@ 2013-01-31 19:44 ` Tom Rini
2013-01-31 20:53 ` Marek Vasut
2 siblings, 1 reply; 5+ messages in thread
From: Tom Rini @ 2013-01-31 19:44 UTC (permalink / raw)
To: u-boot
On Fri, Jan 11, 2013 at 03:35:48AM -0000, Marek Vasut wrote:
> In case a function argument is known/fixed size array in C, the argument is
> still decoyed as pointer instead ( T f(U n[k]) ~= T fn(U *n) ) and therefore
> calling sizeof on the function argument will result in the size of the pointer,
> not the size of the array.
>
> The VFAT code contains such a bug, this patch fixes it.
>
> Reported-by: Aaron Williams <Aaron.Williams@cavium.com>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <tom.rini@gmail.com>
> Cc: Aaron Williams <Aaron.Williams@cavium.com>
> Tested-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130131/d0241b6c/attachment.pgp>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] vfat: Fix mkcksum argument sizes
2013-01-31 19:44 ` [U-Boot] " Tom Rini
@ 2013-01-31 20:53 ` Marek Vasut
0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2013-01-31 20:53 UTC (permalink / raw)
To: u-boot
Dear Tom Rini,
> On Fri, Jan 11, 2013 at 03:35:48AM -0000, Marek Vasut wrote:
> > In case a function argument is known/fixed size array in C, the argument
> > is still decoyed as pointer instead ( T f(U n[k]) ~= T fn(U *n) ) and
> > therefore calling sizeof on the function argument will result in the
> > size of the pointer, not the size of the array.
> >
> > The VFAT code contains such a bug, this patch fixes it.
> >
> > Reported-by: Aaron Williams <Aaron.Williams@cavium.com>
> > Signed-off-by: Marek Vasut <marex@denx.de>
> > Cc: Tom Rini <tom.rini@gmail.com>
> > Cc: Aaron Williams <Aaron.Williams@cavium.com>
> > Tested-by: Michal Simek <michal.simek@xilinx.com>
> > Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
>
> Applied to u-boot/master, thanks!
Can we have a bugfix release 2013.02 or something ? This is a grave bug.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-01-31 20:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-11 13:35 [U-Boot] [PATCH] vfat: Fix mkcksum argument sizes Marek Vasut
2013-01-28 15:12 ` Michal Simek
2013-01-31 15:34 ` Joe Hershberger
2013-01-31 19:44 ` [U-Boot] " Tom Rini
2013-01-31 20:53 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox