Skip to content

Commit 5bd0fd6

Browse files
authored
Rollup merge of #139021 - joboet:pre-vista-fallback, r=ChrisDenton
std: get rid of pre-Vista fallback code We haven't had any Windows XP targets for a long while now... r? ChrisDenton
2 parents 0b40e6e + 3371d49 commit 5bd0fd6

File tree

1 file changed

+6
-22
lines changed
  • library/std/src/sys/pal/windows

1 file changed

+6
-22
lines changed

library/std/src/sys/pal/windows/pipe.rs

+6-22
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res
7474
let ours;
7575
let mut name;
7676
let mut tries = 0;
77-
let mut reject_remote_clients_flag = c::PIPE_REJECT_REMOTE_CLIENTS;
7877
loop {
7978
tries += 1;
8079
name = format!(
@@ -96,7 +95,7 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res
9695
c::PIPE_TYPE_BYTE
9796
| c::PIPE_READMODE_BYTE
9897
| c::PIPE_WAIT
99-
| reject_remote_clients_flag,
98+
| c::PIPE_REJECT_REMOTE_CLIENTS,
10099
1,
101100
PIPE_BUFFER_CAPACITY,
102101
PIPE_BUFFER_CAPACITY,
@@ -112,30 +111,15 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res
112111
//
113112
// Don't try again too much though as this could also perhaps be a
114113
// legit error.
115-
// If `ERROR_INVALID_PARAMETER` is returned, this probably means we're
116-
// running on pre-Vista version where `PIPE_REJECT_REMOTE_CLIENTS` is
117-
// not supported, so we continue retrying without it. This implies
118-
// reduced security on Windows versions older than Vista by allowing
119-
// connections to this pipe from remote machines.
120-
// Proper fix would increase the number of FFI imports and introduce
121-
// significant amount of Windows XP specific code with no clean
122-
// testing strategy
123-
// For more info, see https://github.com/rust-lang/rust/pull/37677.
124114
if handle == c::INVALID_HANDLE_VALUE {
125115
let error = api::get_last_error();
126-
if tries < 10 {
127-
if error == WinError::ACCESS_DENIED {
128-
continue;
129-
} else if reject_remote_clients_flag != 0
130-
&& error == WinError::INVALID_PARAMETER
131-
{
132-
reject_remote_clients_flag = 0;
133-
tries -= 1;
134-
continue;
135-
}
116+
if tries < 10 && error == WinError::ACCESS_DENIED {
117+
continue;
118+
} else {
119+
return Err(io::Error::from_raw_os_error(error.code as i32));
136120
}
137-
return Err(io::Error::from_raw_os_error(error.code as i32));
138121
}
122+
139123
ours = Handle::from_raw_handle(handle);
140124
break;
141125
}

0 commit comments

Comments
 (0)