Mercurial > crates > systemd-socket
diff tests/comm.rs @ 24:1941e9d9819c
Fix unsound manipulation of env vars
Modifying env vars in multi-threaded process is unsound but this crate
was neither checking the number of threads nor mark its functions as
`unsafe`. This change fixes it by both adding a check and adding an
`unsafe` function that can bypass that check if needed.
author | Martin Habovstiak <martin.habovstiak@gmail.com> |
---|---|
date | Fri, 28 Feb 2025 13:52:31 +0100 |
parents | 08b37039504b |
children | cfef4593e207 |
line wrap: on
line diff
--- a/tests/comm.rs Sat Jul 13 15:14:32 2024 +0200 +++ b/tests/comm.rs Fri Feb 28 13:52:31 2025 +0100 @@ -36,6 +36,11 @@ fn main_slave(addr: &str) { use systemd_socket::SocketAddr; + // SAFETY: this is the only thread that's going to mess with systemd sockets. + unsafe { + systemd_socket::init_unprotected().unwrap(); + } + let socket = addr .parse::<SocketAddr>() .expect("failed to parse socket")