Skip to content

Commit 99721c7

Browse files
committed
fix(udp/fast-apple): ignore empty cmsg
1 parent b4378bb commit 99721c7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

quinn-udp/src/cmsg/unix.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ impl MsgHdr for crate::imp::msghdr_x {
4343

4444
fn cmsg_nxt_hdr(&self, cmsg: &Self::ControlMessage) -> *mut Self::ControlMessage {
4545
let selfp = self as *const _ as *mut libc::msghdr;
46-
unsafe { libc::CMSG_NXTHDR(selfp, cmsg) }
46+
let next = unsafe { libc::CMSG_NXTHDR(selfp, cmsg) };
47+
48+
if next.is_null()
49+
|| unsafe { (*next).cmsg_len as usize } < std::mem::size_of::<libc::cmsghdr>()
50+
{
51+
return std::ptr::null_mut();
52+
}
53+
54+
next
4755
}
4856

4957
fn set_control_len(&mut self, len: usize) {

0 commit comments

Comments
 (0)