Skip to content

Commit 16e85d5

Browse files
BerrysoftThomasdezeeuw
authored andcommitted
Assign ss_len if it exists.
1 parent 712e483 commit 16e85d5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/sockaddr.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,23 @@ impl From<SocketAddrV4> for SockAddr {
285285
storage.sin_zero = Default::default();
286286
mem::size_of::<sockaddr_in>() as socklen_t
287287
};
288+
#[cfg(any(
289+
target_os = "dragonfly",
290+
target_os = "freebsd",
291+
target_os = "haiku",
292+
target_os = "hermit",
293+
target_os = "ios",
294+
target_os = "macos",
295+
target_os = "netbsd",
296+
target_os = "nto",
297+
target_os = "openbsd",
298+
target_os = "tvos",
299+
target_os = "vxworks",
300+
target_os = "watchos",
301+
))]
302+
{
303+
storage.ss_len = len as u8;
304+
}
288305
SockAddr { storage, len }
289306
}
290307
}
@@ -311,6 +328,23 @@ impl From<SocketAddrV6> for SockAddr {
311328
}
312329
mem::size_of::<sockaddr_in6>() as socklen_t
313330
};
331+
#[cfg(any(
332+
target_os = "dragonfly",
333+
target_os = "freebsd",
334+
target_os = "haiku",
335+
target_os = "hermit",
336+
target_os = "ios",
337+
target_os = "macos",
338+
target_os = "netbsd",
339+
target_os = "nto",
340+
target_os = "openbsd",
341+
target_os = "tvos",
342+
target_os = "vxworks",
343+
target_os = "watchos",
344+
))]
345+
{
346+
storage.ss_len = len as u8;
347+
}
314348
SockAddr { storage, len }
315349
}
316350
}

0 commit comments

Comments
 (0)