From 8006dd2e57a9b30ff1c978e76c0dcd28d9786ce8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Fri, 20 Jul 2012 15:19:29 +0200 Subject: [PATCH] FAT: get_fatent: Fix FAT boundary check MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- fs/fat/fat.c | 4 ++-- 1 file 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 */ -- 2.25.1