[vlc-devel] [PATCH] Use WSARecv instead of WSARecvFrom when the from field is empty

Denis Charmet typx at videolan.org
Wed Sep 7 19:16:03 CEST 2016


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

Close #17163
---
 compat/recvmsg.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/compat/recvmsg.c b/compat/recvmsg.c
index 5cb56f7..c90900f 100644
--- a/compat/recvmsg.c
+++ b/compat/recvmsg.c
@@ -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)
-- 
2.8.0.rc3



More information about the vlc-devel mailing list