Use WSARecv instead of WSARecvFrom when the from field is empty
authorDenis Charmet <typx@videolan.org>
Wed, 7 Sep 2016 17:08:35 +0000 (19:08 +0200)
committerDenis Charmet <typx@videolan.org>
Wed, 7 Sep 2016 17:08:35 +0000 (19:08 +0200)
Windows will throw WSAEFAULT if WSARecvFrom is called with a NULL lpFrom and/or fromlen

Close #17163

compat/recvmsg.c

index 5cb56f7..c90900f 100644 (file)
@@ -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)