File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ features = ["all"]
38
38
libc = " 0.2.150"
39
39
40
40
[target .'cfg(windows)' .dependencies .windows-sys ]
41
- version = " 0.52"
41
+ version = " >= 0.52,<0.60 "
42
42
features = [
43
43
" Win32_Foundation" ,
44
44
" 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> {
926
926
}
927
927
928
928
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
+
929
940
// `storage` was initialized to zero above, so the path is
930
941
// already null terminated.
931
942
storage. sun_path [ ..bytes. len ( ) ] . copy_from_slice ( bytes) ;
You can’t perform that action at this time.
0 commit comments