Skip to content

Commit 2ff147e

Browse files
committed
Use proper truncation in set_msghdr_iov
1 parent 0e2f962 commit 2ff147e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/sys/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ pub(crate) fn set_msghdr_name(msg: &mut msghdr, name: &SockAddr) {
655655
#[cfg(not(target_os = "redox"))]
656656
pub(crate) fn set_msghdr_iov(msg: &mut msghdr, ptr: *mut libc::iovec, len: usize) {
657657
msg.msg_iov = ptr;
658-
msg.msg_iovlen = len as _;
658+
msg.msg_iovlen = min(len, IovLen::MAX as usize) as IovLen;
659659
}
660660

661661
#[cfg(not(target_os = "redox"))]

src/sys/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub(crate) fn set_msghdr_name(msg: &mut msghdr, name: &SockAddr) {
197197

198198
pub(crate) fn set_msghdr_iov(msg: &mut msghdr, ptr: *mut WSABUF, len: usize) {
199199
msg.lpBuffers = ptr;
200-
msg.dwBufferCount = len as _;
200+
msg.dwBufferCount = min(len, u32::MAX as usize) as u32;
201201
}
202202

203203
pub(crate) fn set_msghdr_control(msg: &mut msghdr, ptr: *mut u8, len: usize) {

0 commit comments

Comments
 (0)