aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorBenoît Thébaudeau <benoit.thebaudeau@advansee.com>2012-07-20 15:19:29 +0200
committerWolfgang Denk <wd@denx.de>2012-09-02 17:14:30 +0200
commit8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8 (patch)
tree601322e517bf6e9805d4e37d410da8e85ff4be6d /fs
parent9795e07b04d8563c181352fd2839643b066a830c (diff)
downloadu-boot-8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8.zip
u-boot-8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8.tar.gz
u-boot-8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8.tar.bz2
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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 9f83572..87a1623 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 */