From: Benoît Thébaudeau Date: Fri, 20 Jul 2012 13:19:29 +0000 (+0200) Subject: FAT: get_fatent: Fix FAT boundary check X-Git-Tag: v2012.10-rc1~90 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8;p=u-boot 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 Cc: Wolfgang Denk --- 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 */