]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #83374 - reyk:fix/bsd-ancillary, r=joshtriplett
authorDylan DPC <dylan.dpc@gmail.com>
Mon, 29 Mar 2021 22:32:21 +0000 (00:32 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Mar 2021 22:32:21 +0000 (00:32 +0200)
unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDs

This adds support for CMSG handling on macOS and fixes it on OpenBSD and possibly other BSDs.

When traversing the CMSG list, the previous code had an exception for Android where the next element after the last pointer could point to the first pointer instead of NULL.  This is actually not specific to Android: the `libc::CMSG_NXTHDR` implementation for Linux and emscripten have a special case to return NULL when the length of the previous element is zero; most other implementations simply return the previous element plus a zero offset in this case.

This MR makes the check non-optional which fixes CMSG handling and a possible endless loop on such systems; tested with file descriptor passing on OpenBSD, Linux, and macOS.

This MR additionally adds `SocketAncillary::is_empty` because clippy is right that it should be added.

This belongs to the `feature(unix_socket_ancillary_data)` tracking issue:  https://github.com/rust-lang/rust/issues/76915

r? `@joshtriplett`


Trivial merge