mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-25 06:00:43 +00:00
fs: fat: fix fatwrite overflow calculation
The overflow calculation was incorrect. Adding the start block of the partition is not needed because the sectors are already relative to the beginning of the partition. If you attempted to write a file smaller than cur_part_info.start blocks on a full partition the old calculation fails to catch the overflow. This would cause an infinite loop in the determine_fatent function. Old, incorrect calculation: ending sector of new file = start sector + file size (in sectors) last sector = partition start + total sectors on the partition Adding the partition start block number is not needed because sectors are already relative to the start of the partition. New calculation: ending sector of new file = start sector + file size (in sectors) last sector = total sectors on the partition Signed-off-by: Reno Farnesi <nfarnesi4@gmail.com>
This commit is contained in:
parent
528f2b66dc
commit
76216211f8
1 changed files with 1 additions and 1 deletions
|
@ -762,7 +762,7 @@ static int check_overflow(fsdata *mydata, __u32 clustnum, loff_t size)
|
|||
if (offset != 0)
|
||||
sect_num++;
|
||||
|
||||
if (startsect + sect_num > cur_part_info.start + total_sector)
|
||||
if (startsect + sect_num > total_sector)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue