diff options
| author | beetrees <b@beetr.ee> | 2022-09-10 11:33:23 +0100 |
|---|---|---|
| committer | beetrees <b@beetr.ee> | 2022-10-01 03:23:08 +0100 |
| commit | c66860ab3ed7861458fca2fba4a7e5f512571537 (patch) | |
| tree | 4e2ef1133e471b26f2a4f3f3856811c5611663ea /library/std/src/sys | |
| parent | 39c0b00cf9e7bf23d90ef7863749590149572ed3 (diff) | |
| download | rust-c66860ab3ed7861458fca2fba4a7e5f512571537.tar.gz rust-c66860ab3ed7861458fca2fba4a7e5f512571537.zip | |
`SetFileTime` doesn't allow setting the file time to `0xFFFF_FFFF_FFFF_FFFF`
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/windows/fs.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs index 155d0297e49..ade00750c95 100644 --- a/library/std/src/sys/windows/fs.rs +++ b/library/std/src/sys/windows/fs.rs @@ -572,6 +572,14 @@ impl File { "Cannot set file timestamp to 0", )); } + let is_max = + |t: c::FILETIME| t.dwLowDateTime == c::DWORD::MAX && t.dwHighDateTime == c::DWORD::MAX; + if times.accessed.map_or(false, is_max) || times.modified.map_or(false, is_max) { + return Err(io::const_io_error!( + io::ErrorKind::InvalidInput, + "Cannot set file timestamp to 0xFFFF_FFFF_FFFF_FFFF", + )); + } cvt(unsafe { c::SetFileTime(self.as_handle(), None, times.accessed.as_ref(), times.modified.as_ref()) })?; |
