sparse_copy() in src/uu/cp/src/platform/linux.rs narrows the source size from u64 to usize with try_into().unwrap():
let size: usize = src_file.metadata()?.size().try_into().unwrap();
On a 32-bit target usize is 32 bits, so any source larger than usize::MAX (≈4 GiB) makes the unwrap() panic instead of copying.
Steps to reproduce
On a 32-bit target (e.g. i686-unknown-linux-gnu or armv7):
$ truncate -s 5G big # cheap 5 GiB sparse file
$ cp --reflink=never --sparse=always big copy
thread 'main' panicked at src/uu/cp/src/platform/linux.rs:170:
called `Result::unwrap()` on an `Err` value: TryFromIntError(())
GNU cp copies the file without error.
Expected
No panic, and no unwrap() (per the project's no-panic rule).
Reported by V12 (finding F-65899).
sparse_copy()insrc/uu/cp/src/platform/linux.rsnarrows the source size fromu64tousizewithtry_into().unwrap():On a 32-bit target
usizeis 32 bits, so any source larger thanusize::MAX(≈4 GiB) makes theunwrap()panic instead of copying.Steps to reproduce
On a 32-bit target (e.g.
i686-unknown-linux-gnuor armv7):GNU
cpcopies the file without error.Expected
No panic, and no
unwrap()(per the project's no-panic rule).Reported by V12 (finding F-65899).