ws2_32: WSARecvMsg allows a NULL control buffer when no control messages arrive.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=43286 Signed-off-by: Damjan Jovanovic <damjan.jov@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b943b8c347
commit
aa2c84a9db
|
@ -878,10 +878,12 @@ static inline int convert_control_headers(struct msghdr *hdr, WSABUF *control)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
|
||||||
/* Set the length of the returned control headers */
|
/* Set the length of the returned control headers */
|
||||||
control->len = (ptr == NULL ? 0 : (char*)ptr - (char*)cmsg_win);
|
control->len = (char*)ptr - (char*)cmsg_win;
|
||||||
return (ptr != NULL);
|
return 1;
|
||||||
|
error:
|
||||||
|
control->len = 0;
|
||||||
|
return 0;
|
||||||
#else /* IP_PKTINFO */
|
#else /* IP_PKTINFO */
|
||||||
control->len = 0;
|
control->len = 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -2108,8 +2108,6 @@ static void test_ip_pktinfo(void)
|
||||||
/* Setup the server side socket */
|
/* Setup the server side socket */
|
||||||
rc=bind(s1, (struct sockaddr*)&s1addr, sizeof(s1addr));
|
rc=bind(s1, (struct sockaddr*)&s1addr, sizeof(s1addr));
|
||||||
ok(rc != SOCKET_ERROR, "bind() failed error: %d\n", WSAGetLastError());
|
ok(rc != SOCKET_ERROR, "bind() failed error: %d\n", WSAGetLastError());
|
||||||
rc=setsockopt(s1, IPPROTO_IP, IP_PKTINFO, (const char*)&yes, sizeof(yes));
|
|
||||||
ok(rc == 0, "failed to set IPPROTO_IP flag IP_PKTINFO!\n");
|
|
||||||
|
|
||||||
/* Build "client" side socket */
|
/* Build "client" side socket */
|
||||||
addrlen = sizeof(s2addr);
|
addrlen = sizeof(s2addr);
|
||||||
|
@ -2133,6 +2131,21 @@ static void test_ip_pktinfo(void)
|
||||||
err=WSAGetLastError();
|
err=WSAGetLastError();
|
||||||
ok(rc == SOCKET_ERROR && err == WSAEFAULT, "WSARecvMsg() failed error: %d (ret = %d)\n", err, rc);
|
ok(rc == SOCKET_ERROR && err == WSAEFAULT, "WSARecvMsg() failed error: %d (ret = %d)\n", err, rc);
|
||||||
|
|
||||||
|
/* Test that when no control data arrives, a 0-length NULL-valued control buffer should succeed */
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
rc=sendto(s2, msg, sizeof(msg), 0, (struct sockaddr*)&s2addr, sizeof(s2addr));
|
||||||
|
ok(rc == sizeof(msg), "sendto() failed error: %d\n", WSAGetLastError());
|
||||||
|
ok(GetLastError() == ERROR_SUCCESS, "Expected 0, got %d\n", GetLastError());
|
||||||
|
hdr.Control.buf = NULL;
|
||||||
|
hdr.Control.len = 0;
|
||||||
|
rc=pWSARecvMsg(s1, &hdr, &dwSize, NULL, NULL);
|
||||||
|
ok(rc == 0, "WSARecvMsg() failed error: %d\n", WSAGetLastError());
|
||||||
|
hdr.Control.buf = pktbuf;
|
||||||
|
|
||||||
|
/* Now start IP_PKTINFO for future tests */
|
||||||
|
rc=setsockopt(s1, IPPROTO_IP, IP_PKTINFO, (const char*)&yes, sizeof(yes));
|
||||||
|
ok(rc == 0, "failed to set IPPROTO_IP flag IP_PKTINFO!\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send a packet from the client to the server and test for specifying
|
* Send a packet from the client to the server and test for specifying
|
||||||
* a short control header.
|
* a short control header.
|
||||||
|
|
Loading…
Reference in New Issue