Skip to content

Commit 38e251b

Browse files
committed
Auto merge of #50079 - NickAtAccuPS:android_abstract_socket, r=sfackler
Android abstract unix domain sockets AddressKind correction The prior check causes abstract unix domain sockets to return AddressKind::Unnamed instead of AddressKind::Abstract on Android. Other than the immediately proceeding comment "macOS seems to return a len of 16 and a zeroed sun_path for unnamed addresses" the check as-implemented does not seem to have alternative explanation. I couldn't find an alternative explanation while stepping though git blame. I suspect the AddressKind::Unnamed nonzero check should instead be if macos, length 16, and zeroed array. @sfackler could you comment on this, the code as-is is the same from your initial addition of abstract uds support.
2 parents 2a6200a + da6142c commit 38e251b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libstd/sys/unix/ext/net.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ impl SocketAddr {
214214
let path = unsafe { mem::transmute::<&[libc::c_char], &[u8]>(&self.addr.sun_path) };
215215

216216
// macOS seems to return a len of 16 and a zeroed sun_path for unnamed addresses
217-
if len == 0 || (cfg!(not(target_os = "linux")) && self.addr.sun_path[0] == 0) {
217+
if len == 0
218+
|| (cfg!(not(any(target_os = "linux", target_os = "android")))
219+
&& self.addr.sun_path[0] == 0)
220+
{
218221
AddressKind::Unnamed
219222
} else if self.addr.sun_path[0] == 0 {
220223
AddressKind::Abstract(&path[1..len])

0 commit comments

Comments
 (0)