From: Marek Vasut Date: Fri, 11 Jan 2013 03:35:48 +0000 (+0000) Subject: vfat: Fix mkcksum argument sizes X-Git-Tag: v2013.01.01~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc8f446c17fe394a085cf6dd1c04ffac869de2b9;p=platform%2Fkernel%2Fu-boot.git 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 Signed-off-by: Marek Vasut Cc: Tom Rini Cc: Aaron Williams Tested-by: Michal Simek Reviewed-by: Joe Hershberger --- 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;