Skip to content

Commit 7d1e2ef

Browse files
fix(net): Fix the WinError 10014 (#954)
* fix(net): Fix the WinError 10014 When sendto_v4 and sendto_v6 are called, the error WinError 10014 is raised, caused by passing the wrong sockaddr_len Note: WSAEFAULT(10014), Bad address. The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument, which is a sockaddr structure, is smaller than the sizeof(sockaddr). * Add testcases for sendto/recvfrom on datagram sockets. --------- Co-authored-by: Dan Gohman <[email protected]>
1 parent 3056dec commit 7d1e2ef

File tree

3 files changed

+730
-2
lines changed

3 files changed

+730
-2
lines changed

src/backend/libc/net/syscalls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub(crate) fn sendto_v4(
100100
send_recv_len(buf.len()),
101101
bitflags_bits!(flags),
102102
as_ptr(&encode_sockaddr_v4(addr)).cast::<c::sockaddr>(),
103-
size_of::<SocketAddrV4>() as _,
103+
size_of::<c::sockaddr_in>() as c::socklen_t,
104104
))
105105
}
106106
}
@@ -119,7 +119,7 @@ pub(crate) fn sendto_v6(
119119
send_recv_len(buf.len()),
120120
bitflags_bits!(flags),
121121
as_ptr(&encode_sockaddr_v6(addr)).cast::<c::sockaddr>(),
122-
size_of::<SocketAddrV6>() as _,
122+
size_of::<c::sockaddr_in6>() as c::socklen_t,
123123
))
124124
}
125125
}

0 commit comments

Comments
 (0)