Commit 0ca74870 authored by Denis Charmet's avatar Denis Charmet

Use WSARecv instead of WSARecvFrom when the from field is empty

Windows will throw WSAEFAULT if WSARecvFrom is called with a NULL lpFrom and/or fromlen

Close #17163
parent 0716db4d
......@@ -54,8 +54,13 @@ ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
DWORD dwFlags = flags;
INT fromlen = msg->msg_namelen;
DWORD rcvd;
int ret = WSARecvFrom(fd, buf, msg->msg_iovlen, &rcvd, &dwFlags,
int ret;
if (fromlen)
ret = WSARecvFrom(fd, buf, msg->msg_iovlen, &rcvd, &dwFlags,
msg->msg_name, &fromlen, NULL, NULL);
else
ret = WSARecv(fd, buf, msg->msg_iovlen, &rcvd, &dwFlags,
NULL, NULL);
free(buf);
if (ret == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment