Skip to content

Commit 73df81f

Browse files
committed
Fix CMSG_NXTHDR for OSX.
This was an oversight from PR #1212. It's been revealed by the new cmsg test.
1 parent be1a8de commit 73df81f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,11 +2777,10 @@ f! {
27772777
return ::CMSG_FIRSTHDR(mhdr);
27782778
};
27792779
let cmsg_len = (*cmsg).cmsg_len as usize;
2780-
let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len as usize)
2781-
+ __DARWIN_ALIGN32(mem::size_of::<::cmsghdr>());
2780+
let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len as usize);
27822781
let max = (*mhdr).msg_control as usize
27832782
+ (*mhdr).msg_controllen as usize;
2784-
if next > max {
2783+
if next + __DARWIN_ALIGN32(mem::size_of::<::cmsghdr>()) > max {
27852784
0 as *mut ::cmsghdr
27862785
} else {
27872786
next as *mut ::cmsghdr
@@ -2800,7 +2799,7 @@ f! {
28002799
}
28012800

28022801
pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
2803-
__DARWIN_ALIGN32(mem::size_of::<::cmsghdr>() + length as usize)
2802+
(__DARWIN_ALIGN32(mem::size_of::<::cmsghdr>()) + length as usize)
28042803
as ::c_uint
28052804
}
28062805

0 commit comments

Comments
 (0)