File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ features = ["all"]
3838libc = " 0.2.150"
3939
4040[target .'cfg(windows)' .dependencies .windows-sys ]
41- version = " 0.52"
41+ version = " >= 0.52,<0.60 "
4242features = [
4343 " Win32_Foundation" ,
4444 " Win32_Networking_WinSock" ,
Original file line number Diff line number Diff line change @@ -926,6 +926,17 @@ pub(crate) fn unix_sockaddr(path: &Path) -> io::Result<SockAddr> {
926926 }
927927
928928 storage. sun_family = crate :: sys:: AF_UNIX as sa_family_t ;
929+
930+ // `windows-sys` 0.52.* represents `SOCKADDR_UN::sun_path` as `&[u8]`, but 0.59.*
931+ // represents it as `&[i8]`.
932+ //
933+ // TODO: Remove this once `windows-sys` 0.52.* is no longer
934+ // permitted as a dependency.
935+ //
936+ // SAFETY: We are safe in doing this, because: `bytes` starts as `&[u8]`, and is converted
937+ // to a `&[u8]` or `&[i8]`, and all of these types have the same size and alignment.
938+ let bytes = unsafe { slice:: from_raw_parts ( bytes. as_ptr ( ) . cast ( ) , bytes. len ( ) ) } ;
939+
929940 // `storage` was initialized to zero above, so the path is
930941 // already null terminated.
931942 storage. sun_path [ ..bytes. len ( ) ] . copy_from_slice ( bytes) ;
You can’t perform that action at this time.
0 commit comments