Commit 1d90c3b457a64aa339aa900199e519ff08440778

Authored by Aaron Williams
Committed by Wolfgang Denk
1 parent a075a79f98

fat: fix FAT sector offsets overflow on large FAT partitions

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>

Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff

... ... @@ -178,12 +178,12 @@
178 178 typedef struct {
179 179 __u8 *fatbuf; /* Current FAT buffer */
180 180 int fatsize; /* Size of FAT in bits */
181   - __u16 fatlength; /* Length of FAT in sectors */
  181 + __u32 fatlength; /* Length of FAT in sectors */
182 182 __u16 fat_sect; /* Starting sector of the FAT */
183   - __u16 rootdir_sect; /* Start sector of root directory */
  183 + __u32 rootdir_sect; /* Start sector of root directory */
184 184 __u16 sect_size; /* Size of sectors in bytes */
185 185 __u16 clust_size; /* Size of clusters in sectors */
186   - short data_begin; /* The sector of the first cluster, can be negative */
  186 + int data_begin; /* The sector of the first cluster, can be negative */
187 187 int fatbufnum; /* Used by get_fatent, init to -1 */
188 188 } fsdata;
189 189