Skip to content

Commit

Permalink
vfat: Fix mkcksum argument sizes
Browse files Browse the repository at this point in the history
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 <[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]>
  • Loading branch information
Marek Vasut authored and trini committed Jan 31, 2013
1 parent 4e5eb45 commit 6ad77d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/fat/fat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6ad77d8

Please sign in to comment.