fix(client): harden ancillary receive parsing

This commit is contained in:
Nils Andreas Svee committed 2026-05-10 20:56:43 +07:00
1 parent 56d3a905ed
commit 1a98858b7a
1 file changed
+7 -1
+7 -1
View File
@@ -66,6 +66,12 @@ pub(crate) fn recv_datagram(
if len < 0 {
return Err(io::Error::last_os_error());
}
let len = usize::try_from(len).map_err(|_| {
io::Error::new(
io::ErrorKind::InvalidData,
"recvmsg returned an unrepresentable datagram length",
)
})?;
let received_at = ClientTimestamp::now();
let meta = unsafe {
// SAFETY: `msg` was initialized by a successful `recvmsg` call. The
@@ -75,7 +81,7 @@ pub(crate) fn recv_datagram(
};
Ok(ReceivedDatagram {
len: len as usize,
len,
received_at,
meta,
})