aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2024-08-09 17:26:27 +0000
committerStefan Eßer <se@FreeBSD.org>2024-08-15 19:05:50 +0000
commite8f52a86ee279a1270e31bc5bad436939e44f555 (patch)
tree33674a88447a51c48a8bc638b3bfdcf9ba6c2713
parent8a4fd438ef6c874110b9ed320d3cd54e2bf93459 (diff)
downloadsrc-e8f52a86ee279a1270e31bc5bad436939e44f555.tar.gz
src-e8f52a86ee279a1270e31bc5bad436939e44f555.zip
msdosfs: fix cluster limit when mounting FAT-16 file systems
The maximum cluster number was calculated based on the number of data cluters that fit in the givem partition size and the size of the FAT area. This limit did not take into account that the highest 10 cluster numbers are reserved and must not be used for files. PR: 280347 Reported by: pho@FreeBSD.org (cherry picked from commit 45d4e82bf61f91792142a2b9e2af657dab8500fd)
-rw-r--r--sys/fs/msdosfs/msdosfs_vfsops.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
index b5392e62b578..4326dc1f0a6d 100644
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -724,7 +724,9 @@ mountmsdosfs(struct vnode *odevvp, struct mount *mp)
}
}
- clusters = (pmp->pm_fatsize / pmp->pm_fatmult) * pmp->pm_fatdiv ;
+ clusters = (pmp->pm_fatsize / pmp->pm_fatmult) * pmp->pm_fatdiv;
+ if (clusters >= (CLUST_RSRVD & pmp->pm_fatmask))
+ clusters = CLUST_RSRVD & pmp->pm_fatmask;
if (pmp->pm_maxcluster >= clusters) {
#ifdef MSDOSFS_DEBUG
printf("Warning: number of clusters (%ld) exceeds FAT "