Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111636756
D23082.id66479.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D23082.id66479.diff
View Options
Index: sbin/fsck_msdosfs/boot.c
===================================================================
--- sbin/fsck_msdosfs/boot.c
+++ sbin/fsck_msdosfs/boot.c
@@ -266,8 +266,11 @@
return FSFATAL;
}
- boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / boot->bpbSecPerClust +
- CLUST_FIRST;
+ /*
+ * The number of clusters is derived from available data sectors, divided
+ * by sectors per cluster.
+ */
+ boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / boot->bpbSecPerClust;
if (boot->flags & FAT32) {
if (boot->NumClusters > (CLUST_RSRVD & CLUST32_MASK)) {
@@ -310,11 +313,19 @@
break;
}
- if (boot->NumFatEntries < boot->NumClusters - CLUST_FIRST) {
+ if (boot->NumFatEntries < boot->NumClusters) {
pfatal("FAT size too small, %u entries won't fit into %u sectors\n",
boot->NumClusters, boot->FATsecs);
return FSFATAL;
}
+
+ /*
+ * There are two reserved clusters. To avoid adding CLUST_FIRST every time
+ * when we perform boundary checks, we increment the NumClusters by 2,
+ * which is CLUST_FIRST to denote the first out-of-range cluster number.
+ */
+ boot->NumClusters += CLUST_FIRST;
+
boot->ClusterSize = boot->bpbBytesPerSec * boot->bpbSecPerClust;
boot->NumFiles = 1;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 7, 8:25 AM (19 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17028305
Default Alt Text
D23082.id66479.diff (1 KB)
Attached To
Mode
D23082: sbin/fsck_msdosfs: Correct off-by-two issue when determining FAT type.
Attached
Detach File
Event Timeline
Log In to Comment