aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2013-01-11 03:35:48 +0000
committerFathi Boudra <fathi.boudra@linaro.org>2013-03-27 09:51:25 +0200
commit9029fee1c788443a60f4a3a537eaf976b64f4ab7 (patch)
treeb25fee4fa06bdefc7ef06ccbdd8772b2172d13ba
parentb4eb22a60d15240d280785df7948448824d86fe5 (diff)
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. 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>
-rw-r--r--fs/fat/fat.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 393c3781e..25d3318cd 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;