]> Git Repo - u-boot.git/commitdiff
vfat: Fix mkcksum argument sizes
authorMarek Vasut <[email protected]>
Fri, 11 Jan 2013 03:35:48 +0000 (03:35 +0000)
committerTom Rini <[email protected]>
Thu, 31 Jan 2013 19:43:01 +0000 (14:43 -0500)
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]>
fs/fat/fat.c

index 393c3781eb65ba8201339042dc44531f9a36df39..25d3318cd0a8d8baaefee5cd6bc91977511a08ac 100644 (file)
@@ -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;
This page took 0.036616 seconds and 4 git commands to generate.