Commit 4259f933 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ws2_32: Manage shorter length for TCP_NODELAY.

parent c2e2e919
......@@ -1725,6 +1725,12 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl
switch(optname)
{
case TCP_NODELAY:
if (*optlen < 1 || !optval)
{
SetLastError( WSAEFAULT );
return SOCKET_ERROR;
}
*optlen = 1;
return server_getsockopt( s, IOCTL_AFD_WINE_GET_TCP_NODELAY, optval, optlen );
default:
......@@ -2998,14 +3004,14 @@ int WINAPI setsockopt( SOCKET s, int level, int optname, const char *optval, int
switch(optname)
{
case TCP_NODELAY:
{
INT nodelay = *optval;
if (optlen <= 0) {
SetLastError(WSAEFAULT);
if (optlen <= 0 || !optval)
{
SetLastError( optlen && optval ? WSAENOBUFS : WSAEFAULT );
return SOCKET_ERROR;
}
return server_setsockopt( s, IOCTL_AFD_WINE_SET_TCP_NODELAY, (char*)&nodelay, sizeof(nodelay) );
}
value = *optval;
return server_setsockopt( s, IOCTL_AFD_WINE_SET_TCP_NODELAY, (char*)&value, sizeof(value) );
default:
FIXME("Unknown IPPROTO_TCP optname 0x%08x\n", optname);
SetLastError(WSAENOPROTOOPT);
......
......@@ -1181,6 +1181,7 @@ static void test_set_getsockopt(void)
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_SNDBUF, FALSE, {1, 2, 4}, {0xdeadbe00, 0xdead0000}, TRUE},
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_SNDTIMEO, FALSE, {1, 2, 4}, {0}, TRUE},
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_OPENTYPE, FALSE, {1, 2, 4}, {0}, TRUE},
{AF_INET, SOCK_STREAM, IPPROTO_TCP, TCP_NODELAY, TRUE, {1, 1, 1}, {0}, TRUE},
{AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_MULTICAST_LOOP, TRUE, {1, 1, 4}, {0}, TRUE, TRUE},
{AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_MULTICAST_TTL, TRUE, {1, 1, 4}, {0}, FALSE},
{AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_TOS, TRUE, {1, 1, 4}, {0}, FALSE},
......
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