diff mbox

[U-Boot,v2,2/8] FAT: get_fatent: Fix FAT boundary check

Message ID 907420307.332540.1342790369965.JavaMail.root@advansee.com
State Accepted
Headers show

Commit Message

Benoît Thébaudeau July 20, 2012, 1:19 p.m. UTC
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>
---
Changes for v2:
 - Patch renumbering because of the new v2 1/8.
 - Possible code style changes due to the new v2 1/8.

 .../fs/fat/fat.c                                   |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Wolfgang Denk Sept. 2, 2012, 3:14 p.m. UTC | #1
Dear Benoît Thébaudeau,

In message <907420307.332540.1342790369965.JavaMail.root@advansee.com> you wrote:
> 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>
> ---
> Changes for v2:
>  - Patch renumbering because of the new v2 1/8.
>  - Possible code style changes due to the new v2 1/8.
>
>  .../fs/fat/fat.c                                   |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git u-boot-66714b1.orig/fs/fat/fat.c u-boot-66714b1/fs/fat/fat.c
index 9f83572..87a1623 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 */