From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Beno=C3=AEt_Th=C3=A9baudeau?= Date: Fri, 20 Jul 2012 00:01:17 +0200 (CEST) Subject: [U-Boot] [PATCH 1/7] FAT: get_fatent: Fix FAT boundary check Message-ID: <141350874.294112.1342735277057.JavaMail.root@advansee.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 u-boot-66714b1.orig/fs/fat/fat.c u-boot-66714b1/fs/fat/fat.c index bc46cc5..f6fd457 100644 --- u-boot-66714b1.orig/fs/fat/fat.c +++ u-boot-66714b1/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 */