]> git.sur5r.net Git - u-boot/commitdiff
FAT: get_fatent: Fix FAT boundary check
authorBenoît Thébaudeau <benoit.thebaudeau@advansee.com>
Fri, 20 Jul 2012 13:19:29 +0000 (15:19 +0200)
committerWolfgang Denk <wd@denx.de>
Sun, 2 Sep 2012 15:14:30 +0000 (17:14 +0200)
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>
fs/fat/fat.c

index 9f835725247eaae1b96250b3c2b14eadcd34e980..87a1623d19682d579daef033482841359d1c62c3 100644 (file)
@@ -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 */