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)
Fri, Apr 12, 9:04 AM
Unknown Object (File)
Mar 22 2024, 10:25 AM
Unknown Object (File)
Mar 22 2024, 9:46 AM
Unknown Object (File)
Mar 9 2024, 11:11 AM
Unknown Object (File)
Mar 9 2024, 10:58 AM
Unknown Object (File)
Feb 12 2024, 9:17 PM
Unknown Object (File)
Dec 23 2023, 1:13 PM
Unknown Object (File)
Oct 11 2023, 6:44 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