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, Jul 16, 9:27 AM
Unknown Object (File)
Jun 27 2025, 8:49 PM
Unknown Object (File)
Jun 22 2025, 11:20 PM
Unknown Object (File)
Jun 16 2025, 6:42 AM
Unknown Object (File)
Jun 12 2025, 6:48 PM
Unknown Object (File)
Jun 12 2025, 4:14 PM
Unknown Object (File)
Jun 11 2025, 7:02 PM
Unknown Object (File)
Jun 11 2025, 9:34 AM
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 Not Applicable
Unit
Tests Not Applicable