From 29f15aabedbf0512db89e623c2480f92cbb24000 Mon Sep 17 00:00:00 2001 From: chenbaiyu Date: Sat, 8 Jan 2022 01:39:54 +0800 Subject: [PATCH] fix security problem caused server hang and unexpected input behavior at pre-login window when macOS version on Big Sur or above --- .cargo/config.toml | 4 ++++ src/server/connection.rs | 8 +++----- 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 000000000..f19d0f027 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,4 @@ +[target.'cfg(target_os="macos")'] +rustflags = [ + "-C", "link-args=-sectcreate __CGPreLoginApp __cgpreloginapp /dev/null", +] \ No newline at end of file diff --git a/src/server/connection.rs b/src/server/connection.rs index 75a9071f8..ac971aafd 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -904,12 +904,10 @@ async fn start_ipc( mut rx_to_cm: mpsc::UnboundedReceiver, tx_from_cm: mpsc::UnboundedSender, ) -> ResultType<()> { - loop { - if !crate::platform::is_prelogin() { - break; - } - sleep(1.).await; + if crate::platform::is_prelogin() { + return Ok(()); } + let mut stream = None; if let Ok(s) = crate::ipc::connect(1000, "_cm").await { stream = Some(s);