Doing unaligned reads is not supported on all architectures, use
byte sized reads of the little endian buffer.
Rename off16 to off8, as it reflects the buffer offset in byte
granularity (offset is in entry, i.e. 12 bit, granularity).
Fix a regression introduced in
bba703a5b508c786bf37f90fd238f23cea781a66
Reported-by: Oleksandr Tymoshenko <gonzo@bluezbox.com>
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Tested-by: Oleksandr Tymoshenko <gonzo@bluezbox.com>
static __u32 get_fatent(fsdata *mydata, __u32 entry)
{
__u32 bufnum;
- __u32 off16, offset;
+ __u32 offset, off8;
__u32 ret = 0x00;
if (CHECK_CLUST(entry, mydata->fatsize)) {
ret = FAT2CPU16(((__u16 *) mydata->fatbuf)[offset]);
break;
case 12:
- off16 = (offset * 3) / 2;
- ret = FAT2CPU16(*(__u16 *)(mydata->fatbuf + off16));
+ off8 = (offset * 3) / 2;
+ /* fatbut + off8 may be unaligned, read in byte granularity */
+ ret = mydata->fatbuf[off8] + (mydata->fatbuf[off8 + 1] << 8);
if (offset & 0x1)
ret >>= 4;