diff options
| author | Dan Gohman <dev@sunfishcode.online> | 2023-02-23 04:56:31 -0800 |
|---|---|---|
| committer | Dan Gohman <dev@sunfishcode.online> | 2023-02-23 06:29:11 -0800 |
| commit | c0c1925774bc07a25bd6a3f07f75abf274183cfb (patch) | |
| tree | 08b7892b64435b01e26b735a2475a243b6d7f77a /library/std/src/sys/windows/c.rs | |
| parent | 07c993eba8b76eae497e98433ae075b00f01be10 (diff) | |
| download | rust-c0c1925774bc07a25bd6a3f07f75abf274183cfb.tar.gz rust-c0c1925774bc07a25bd6a3f07f75abf274183cfb.zip | |
Fix `is_terminal`'s handling of long paths on Windows.
As reported in sunfishcode/is-terminal#18, there are situations where `GetFileInformationByHandleEx` can write a file name length that is longer than the provided buffer. To avoid deferencing memory past the end of the buffer, use a bounds-checked function to form a slice to the buffer and handle the out-of-bounds case. This ports the fix from sunfishcode/is-terminal#19 to std's `is_terminal` implementation.
Diffstat (limited to 'library/std/src/sys/windows/c.rs')
| -rw-r--r-- | library/std/src/sys/windows/c.rs | 8 |
1 files changed, 0 insertions, 8 deletions
diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index f58dcf1287b..1d0ab772739 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -539,14 +539,6 @@ pub struct SYMBOLIC_LINK_REPARSE_BUFFER { pub PathBuffer: WCHAR, } -/// NB: Use carefully! In general using this as a reference is likely to get the -/// provenance wrong for the `PathBuffer` field! -#[repr(C)] -pub struct FILE_NAME_INFO { - pub FileNameLength: DWORD, - pub FileName: [WCHAR; 1], -} - #[repr(C)] pub struct MOUNT_POINT_REPARSE_BUFFER { pub SubstituteNameOffset: c_ushort, |
