Page MenuHomeFreeBSD

sbin/fsck_msdosfs: Correct off-by-two issue when determining FAT type.
ClosedPublic

Authored by delphij on Wed, Jan 8, 8:56 AM.

Details

Summary

Correct off-by-two issue when determining FAT type.

In the code we used NumClusters as the upper (non-inclusive) boundary
of valid cluster number, so the actual value was 2 (CLUST_FIRST) more
than the real number of clusters. This causes a FAT16 media with
65524 clusters be treated as FAT32 and might affect FAT12 media with
4084 clusters as well.

To fix this, we increment NumClusters by CLUST_FIRST after the type
determination.

PR: 243179

Test Plan

Create FAT16 media on a 2GiB storage and run fsck_msdosfs

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

delphij created this revision.Wed, Jan 8, 8:56 AM
delphij edited the summary of this revision. (Show Details)Wed, Jan 8, 8:57 AM
delphij updated this revision to Diff 66585.Fri, Jan 10, 6:35 AM

Sync with NetBSD which added more boundary checks.

delphij edited the summary of this revision. (Show Details)Fri, Jan 10, 6:57 AM
delphij updated this revision to Diff 66610.Sat, Jan 11, 4:05 AM

Reduce the patch back to original (NetBSD sync was merged).

delphij edited the summary of this revision. (Show Details)Sat, Jan 11, 4:05 AM
This revision was not accepted when it landed; it landed in state Needs Review.Sat, Jan 11, 5:41 PM
This revision was automatically updated to reflect the committed changes.