Page MenuHomeFreeBSD

Fix an integer overflow on 32-bit platforms.
ClosedPublic

Authored by delphij on Sep 22 2020, 9:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 12, 7:29 PM
Unknown Object (File)
Tue, Nov 4, 10:49 PM
Unknown Object (File)
Fri, Oct 24, 9:22 PM
Unknown Object (File)
Oct 15 2025, 8:31 AM
Unknown Object (File)
Oct 13 2025, 6:54 AM
Unknown Object (File)
Oct 12 2025, 1:53 PM
Unknown Object (File)
Oct 7 2025, 2:00 PM
Unknown Object (File)
Oct 6 2025, 11:56 PM
Subscribers

Details

Summary

sbin/fsck_msdosfs: Fix an integer overflow on 32-bit platforms.

The purpose of checksize() is to verify that the referenced cluster chain
size matches the recorded file size (up to 2^32 - 1) in the directory
entry. We follow the cluster chain, then multiple the cluster count by
bytes per cluster to get the physical size, and then examine it against
the recorded size.

When a file is close to 4 GiB (between 4GiB - cluster size and 4GiB, both
non-inclusive), the product of cluster count and bytes per cluster would
be exactly 4 GiB. On 32-bit systems, because size_t is 32-bit, this would
wrap back to 0, which will cause the file be truncated to 0.

Fix this by using 64-bit physicalSize instead.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 33740
Build 30969: arc lint + arc unit