clipboard (unix): FILETIME conversion wraps for file times after 2554
Follow-up to #16366. The unix file clipboard converts FILETIME <-> SystemTime through a u64 count of nanoseconds, which only reaches 2554-07-21 (1970 + 2^64 ns). Anything later wraps in both directions.
Receive (libs/clipboard/src/platform/unix/filetype.rs:171)
let last_write_time = (last_write_time - LDAP_EPOCH_DELTA) * 100;The FILETIME comes from the peer. For any value after 2554 the multiply overflows: debug builds panic (attempt to multiply with overflow), release builds wrap to a wrong date.
Send (libs/clipboard/src/platform/unix/local_file.rs:167)
.as_nanos() as u64 / 100 + LDAP_EPOCH_DELTAas_nanos() is u128; the as u64 cast truncates before the division.
| mtime | FILETIME | send today | receive today |
|---|---|---|---|
| 3000-01-01 00:00:00 UTC | 441481536000000000 |
257014095262904483 (= 2415-06-13) |
panic (debug) / 2415-06-13 (release) |
Repro: touch -t 300001010000 f on Linux/macOS and copy it, or a peer sending a FILETIME for year 3000 (Windows accepts dates up to year 30827).
Dividing the u128 before narrowing and building the Duration from seconds + remainder keeps both sides exact for the whole u64 FILETIME range.
Source: rustdesk/rustdesk