Commit bc8f446c17fe394a085cf6dd1c04ffac869de2b9

Authored by Marek Vasut
Committed by Tom Rini
1 parent ad394e027f
Exists in u-boot-2013.01.y

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>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

... ... @@ -569,9 +569,9 @@
569 569  
570 570 __u8 ret = 0;
571 571  
572   - for (i = 0; i < sizeof(name); i++)
  572 + for (i = 0; i < 8; i++)
573 573 ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + name[i];
574   - for (i = 0; i < sizeof(ext); i++)
  574 + for (i = 0; i < 3; i++)
575 575 ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + ext[i];
576 576  
577 577 return ret;