Bug
library/std/src/sys/fs/windows.rs File::truncate does size as i64 for FILE_END_OF_FILE_INFO::EndOfFile. Values above i64::MAX wrap to negative sizes, which is not a valid user-facing contract.
Origin
Windows FS port used a direct cast; Unix uses try_into() for off_t/off64_t and returns InvalidInput on overflow.
Impact
Caller-controlled sizes from untrusted configs/protocols (object stores, archives, IPC) can pass huge u64 values and get wrong/erroneous truncation behavior instead of a clean error. Availability/correctness issue on Windows only.
Fix
size.try_into::<i64>() with io::ErrorKind::InvalidInput on failure, matching Unix.
Bug
library/std/src/sys/fs/windows.rsFile::truncatedoessize as i64forFILE_END_OF_FILE_INFO::EndOfFile. Values abovei64::MAXwrap to negative sizes, which is not a valid user-facing contract.Origin
Windows FS port used a direct cast; Unix uses
try_into()foroff_t/off64_tand returnsInvalidInputon overflow.Impact
Caller-controlled sizes from untrusted configs/protocols (object stores, archives, IPC) can pass huge
u64values and get wrong/erroneous truncation behavior instead of a clean error. Availability/correctness issue on Windows only.Fix
size.try_into::<i64>()withio::ErrorKind::InvalidInputon failure, matching Unix.