diff mbox

[U-Boot] fat: fix FAT sector offsets overflow on large FAT partitions

Message ID 1337448040-7902-1-git-send-email-agust@denx.de
State Accepted
Commit 1d90c3b457a64aa339aa900199e519ff08440778
Delegated to: Anatolij Gustschin
Headers show

Commit Message

Anatolij Gustschin May 19, 2012, 5:20 p.m. UTC
From: Aaron Williams <aaron.williams@caviumnetworks.com>

This patch fixes several issues where sector offsets can overflow due
to being limited to 16-bits. The cases where an overflow can happen
when accessing large FAT32 partitions are:

 - length of FAT in sectors
 - start sector of root directory
 - the sector of the first cluster

These issues were observed when reading files from a 64GB FAT32
filesystem.

Signed-off-by: Aaron Williams <aaron.williams@caviumnetworks.com>
Tested-by: Anatolij Gustschin <agust@denx.de>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 include/fat.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Comments

Wolfgang Denk May 22, 2012, 8:14 a.m. UTC | #1
Dear Anatolij Gustschin,

In message <1337448040-7902-1-git-send-email-agust@denx.de> you wrote:
> From: Aaron Williams <aaron.williams@caviumnetworks.com>
> 
> This patch fixes several issues where sector offsets can overflow due
> to being limited to 16-bits. The cases where an overflow can happen
> when accessing large FAT32 partitions are:
> 
>  - length of FAT in sectors
>  - start sector of root directory
>  - the sector of the first cluster
> 
> These issues were observed when reading files from a 64GB FAT32
> filesystem.
> 
> Signed-off-by: Aaron Williams <aaron.williams@caviumnetworks.com>
> Tested-by: Anatolij Gustschin <agust@denx.de>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
>  include/fat.h |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/include/fat.h b/include/fat.h
index 4c92442..f1b4a0d 100644
--- a/include/fat.h
+++ b/include/fat.h
@@ -178,12 +178,12 @@  typedef struct dir_slot {
 typedef struct {
 	__u8	*fatbuf;	/* Current FAT buffer */
 	int	fatsize;	/* Size of FAT in bits */
-	__u16	fatlength;	/* Length of FAT in sectors */
+	__u32	fatlength;	/* Length of FAT in sectors */
 	__u16	fat_sect;	/* Starting sector of the FAT */
-	__u16	rootdir_sect;	/* Start sector of root directory */
+	__u32	rootdir_sect;	/* Start sector of root directory */
 	__u16	sect_size;	/* Size of sectors in bytes */
 	__u16	clust_size;	/* Size of clusters in sectors */
-	short	data_begin;	/* The sector of the first cluster, can be negative */
+	int	data_begin;	/* The sector of the first cluster, can be negative */
 	int	fatbufnum;	/* Used by get_fatent, init to -1 */
 } fsdata;