diff options
author | Benoît Thébaudeau <benoit.thebaudeau@advansee.com> | 2012-07-20 15:19:29 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2012-09-02 17:14:30 +0200 |
commit | 8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8 (patch) | |
tree | 601322e517bf6e9805d4e37d410da8e85ff4be6d /fs | |
parent | 9795e07b04d8563c181352fd2839643b066a830c (diff) | |
download | u-boot-midas-8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8.tar.gz u-boot-midas-8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8.tar.bz2 u-boot-midas-8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8.zip |
FAT: get_fatent: Fix FAT boundary check
startblock must be taken into account in order not to read past the
end of the FAT.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fat/fat.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 9f83572524..87a1623d19 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -207,8 +207,8 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry) __u32 fatlength = mydata->fatlength; __u32 startblock = bufnum * FATBUFBLOCKS; - if (getsize > fatlength) - getsize = fatlength; + if (startblock + getsize > fatlength) + getsize = fatlength - startblock; fatlength *= mydata->sect_size; /* We want it in bytes now */ startblock += mydata->fat_sect; /* Offset from start of disk */ |