diff options
| author | LinkTed <link.ted@mailbox.org> | 2020-11-24 19:24:39 +0100 |
|---|---|---|
| committer | LinkTed <link.ted@mailbox.org> | 2020-11-24 22:15:04 +0100 |
| commit | 9b9dd4aeea858fb2249adc9421ab156a78e84b8b (patch) | |
| tree | 320b6bb64045a19c6396ce2df55efc4c69460aaa | |
| parent | ead7185db69d84e6af53712508600cad136f972b (diff) | |
| download | rust-9b9dd4aeea858fb2249adc9421ab156a78e84b8b.tar.gz rust-9b9dd4aeea858fb2249adc9421ab156a78e84b8b.zip | |
Bug fix for android platform, because of the wrong behavior of CMSG_NXTHDR
| -rw-r--r-- | library/std/src/sys/unix/ext/net/ancillary.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/ext/net/ancillary.rs b/library/std/src/sys/unix/ext/net/ancillary.rs index a68475ab985..a94456b4e7a 100644 --- a/library/std/src/sys/unix/ext/net/ancillary.rs +++ b/library/std/src/sys/unix/ext/net/ancillary.rs @@ -5,6 +5,8 @@ use crate::marker::PhantomData; use crate::mem::{size_of, zeroed}; use crate::os::unix::io::RawFd; use crate::path::Path; +#[cfg(target_os = "android")] +use crate::ptr::eq; use crate::ptr::read_unaligned; use crate::slice::from_raw_parts; use crate::sys::net::Socket; @@ -157,6 +159,13 @@ fn add_to_ancillary_data<T>( while !cmsg.is_null() { previous_cmsg = cmsg; cmsg = libc::CMSG_NXTHDR(&msg, cmsg); + cfg_if::cfg_if! { + if #[cfg(target_os = "android")] { + if cmsg == previous_cmsg { + break; + } + } + } } if previous_cmsg.is_null() { @@ -420,6 +429,16 @@ impl<'a> Iterator for Messages<'a> { }; let cmsg = cmsg.as_ref()?; + cfg_if::cfg_if! { + if #[cfg(target_os = "android")] { + if let Some(current) = self.current { + if eq(current, cmsg) { + return None; + } + } + } + } + self.current = Some(cmsg); let ancillary_result = AncillaryData::try_from_cmsghdr(cmsg); Some(ancillary_result) |
