Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F169605674
D12124.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
D12124.diff
View Options
Index: head/sys/fs/msdosfs/msdosfs_fat.c
===================================================================
--- head/sys/fs/msdosfs/msdosfs_fat.c
+++ head/sys/fs/msdosfs/msdosfs_fat.c
@@ -908,19 +908,17 @@
* zero. These represent free clusters.
*/
pmp->pm_freeclustercount = 0;
- for (cn = CLUST_FIRST; cn <= pmp->pm_maxcluster; cn++) {
+ for (cn = 0; cn <= pmp->pm_maxcluster; cn++) {
byteoffset = FATOFS(pmp, cn);
bo = byteoffset % pmp->pm_fatblocksize;
- if (!bo || !bp) {
+ if (bo == 0) {
/* Read new FAT block */
- if (bp)
+ if (bp != NULL)
brelse(bp);
fatblock(pmp, byteoffset, &bn, &bsize, NULL);
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
+ if (error != 0)
return (error);
- }
}
if (FAT32(pmp))
readcn = getulong(&bp->b_data[bo]);
@@ -930,7 +928,19 @@
readcn >>= 4;
readcn &= pmp->pm_fatmask;
- if (readcn == CLUST_FREE)
+ /*
+ * Check if the FAT ID matches the BPB's media descriptor and
+ * all other bits are set to 1.
+ */
+ if (cn == 0 && readcn != ((pmp->pm_fatmask & 0xffffff00) |
+ pmp->pm_bpb.bpbMedia)) {
+#ifdef MSDOSFS_DEBUG
+ printf("mountmsdosfs(): Media descriptor in BPB"
+ "does not match FAT ID\n");
+#endif
+ brelse(bp);
+ return (EINVAL);
+ } else if (readcn == CLUST_FREE)
usemap_free(pmp, cn);
}
if (bp != NULL)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Sep 3, 1:21 AM (16 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38043558
Default Alt Text
D12124.diff (1 KB)
Attached To
Mode
D12124: msdosfs: verify that the BPB media descriptor and FAT ID match
Attached
Detach File
Event Timeline
Log In to Comment