Commit bc8f446c authored by Marek Vasut's avatar Marek Vasut Committed by Tom Rini
Browse files

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: default avatarAaron Williams <Aaron.Williams@cavium.com>
Signed-off-by: Marek Vasut's avatarMarek Vasut <marex@denx.de>
Cc: Tom Rini <tom.rini@gmail.com>
Cc: Aaron Williams <Aaron.Williams@cavium.com>
Tested-by: default avatarMichal Simek <michal.simek@xilinx.com>
Reviewed-by: Joe Hershberger's avatarJoe Hershberger <joe.hershberger@ni.com>
parent ad394e02
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment