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, Dec 20, 12:46 AM
Unknown Object (File)
Oct 20 2024, 1:15 PM
Unknown Object (File)
Oct 13 2024, 8:09 PM
Unknown Object (File)
Sep 30 2024, 2:18 PM
Unknown Object (File)
Sep 25 2024, 3:22 AM
Unknown Object (File)
Sep 15 2024, 8:37 AM
Unknown Object (File)
Sep 4 2024, 1:44 PM
Unknown Object (File)
Aug 17 2024, 6:55 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 Not Applicable
Unit
Tests Not Applicable