vfat: Fix mkcksum argument sizes
PATCH 1/1 vfat: Fix mkcksum argument sizes
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.
--- fs/fat/fat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fat/fat.c +2 -2
@@ -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;
Signature · 1 line
1.7.10.4
PATCH 1/1 vfat: Fix mkcksum argument sizes
2013/1/11 Marek Vasut <[email protected]>:
Quoted 7 lines
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])~= Tfn(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.
Quoted 7 lines
Reported-by Aaron Williams <[email protected]>Signed-off-by Marek Vasut <[email protected]>Cc Tom Rini <[email protected]>Cc Aaron Williams <[email protected]>--- fs/fat/fat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Thanks,
Michal
Signature · 5 lines
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
PATCH 1/1 vfat: Fix mkcksum argument sizes
In reply to Marek VasutQuoted 21 lines · Marek Vasut
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])~= Tfn(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 <[email protected]>Signed-off-by Marek Vasut <[email protected]>Cc Tom Rini <[email protected]>Cc Aaron Williams <[email protected]>--- fs/fat/fat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/fat/fat.c +0
-0@@ -569,9 +569,9 @@ static __u8 mkcksum(const char name[8], const char ext[3])
fs/fat/fat.c static __u8 mkcksum(const char name[8], const char ext[3]) · line 577
Quoted 10 lines
fs/fat/fat.c +2
-2__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;
Quoted 5 lines · Marek Vasut
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])~= Tfn(U *n)) and therefore calling sizeof on the function argument will result in the size of the pointer, not the size of the array.
Quoted 8 lines
The VFAT code contains such a bug, this patch fixes it.
Reported-by Aaron Williams <[email protected]>Signed-off-by Marek Vasut <[email protected]>Cc Tom Rini <[email protected]>Cc Aaron Williams <[email protected]>Tested-by Michal Simek <[email protected]>Reviewed-by Joe Hershberger <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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>
Dear Tom Rini,
Quoted 8 lines · Marek Vasut
Quoted 7 lines
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])~= Tfn(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.
Quoted 8 lines
Quoted 6 lines
Reported-by Aaron Williams <[email protected]>Signed-off-by Marek Vasut <[email protected]>Cc Tom Rini <[email protected]>Cc Aaron Williams <[email protected]>Tested-by Michal Simek <[email protected]>Reviewed-by Joe Hershberger <[email protected]>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