Page MenuHomeFreeBSD

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

Authored by delphij on Jan 8 2020, 8:56 AM.
Tags
None
Referenced Files
F157035324: D23082.id66585.diff
Mon, May 18, 1:44 AM
F157035316: D23082.id66610.diff
Mon, May 18, 1:44 AM
F157035308: D23082.id66479.diff
Mon, May 18, 1:44 AM
F157035307: D23082.id66631.diff
Mon, May 18, 1:44 AM
F157033934: D23082.diff
Mon, May 18, 1:32 AM
Unknown Object (File)
Sat, May 2, 11:35 AM
Unknown Object (File)
Tue, Apr 21, 1:37 PM
Unknown Object (File)
Sun, Apr 19, 3:50 PM
Subscribers

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 - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 28601
Build 26637: arc lint + arc unit

Event Timeline

Sync with NetBSD which added more boundary checks.

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

This revision was not accepted when it landed; it landed in state Needs Review.Jan 11 2020, 5:41 PM
This revision was automatically updated to reflect the committed changes.